Foutje?

Gestart doorSebastiaanh10 reacties47 weergaven

11 berichten · pagina 1 van 1

Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo One2xs,
Ik ben bezig met mijn nieuwe project, maar loop ergens op vast. Op het forum laat hij bij mij de rang Schandaal! (verbannen) zien, maar op de ledenlijst staat er gewoon Keizer. Ik gebruik daarvoor dezelfde code.

function rang(){
      if($lFetch[rang] == 0){
        return Schandaal!;
      }elseif($lFetch[rang] == 1){
        return Burger;
      }elseif($lFetch[rang] == 2){
        return Senaat;
      }else{
        return Keizer;
      }
    }


$lQuery = mysql_query("SELECT * FROM leden WHERE naam = " . mysql_real_escape_string($t2Fetch[poster]) . " ") or die(mysql_error());
    $lFetch = mysql_fetch_assoc($lQuery);


Wie weet wat er fout is?

Mvg,
SebastiaanH

toevoeging op 18 februari 2012, 20:43:03:

echo <div id="foruminfo" /> <b>  . ucfirst(htmlentities($t2Fetch[poster])) .  </b> <br />  . rang() . </div><div id="forumpost" />  . ucfirst(htmlentities($t2Fetch[startpost])) .  </div> ;
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
mag ik de volledige code? Ik zou het trouwens anders aanpakken

toevoeging op 18 februari 2012, 20:47:12:

[COLOR= #0000BB]<?php[/COLOR]
    [COLOR= #007700]function[/COLOR] rang[COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]){[/COLOR]
 [COLOR= #0000BB]$lolQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$lolFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lolQuery[/COLOR][COLOR= #007700]);[/COLOR]

      [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lolFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Schandaal![/COLOR][COLOR= #007700];
      }[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lolFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Burger[/COLOR][COLOR= #007700];
      }[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lolFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Senaat[/COLOR][COLOR= #007700];
      }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Keizer[/COLOR][COLOR= #007700];
      }
    }[/COLOR]
?>
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Werkt niet, hij blijft Schandaal! laten zien.
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Er zaten wat foutjes in, het is nu opgelost. je roept hem zo aan:

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] rang[COLOR= #007700]([/COLOR]useridwaarvanjerangwilt[COLOR= #007700]);[/COLOR] ?>
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja dat snap ik. yummie
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wheeerkt die??
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja, nu wel. Bedankt smile
toevoeging op 18 februari 2012, 20:52:16:
Het topic mag open blijven voor als ik nog een andere fout heb.
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ik zou voor zoveel elseifjes een switch gebruiken.
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
    [COLOR= #007700]function[/COLOR] rang[COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]){[/COLOR]
        [COLOR= #0000BB]$lolQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT rang FROM leden WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$lolFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lolQuery[/COLOR][COLOR= #007700]);[/COLOR]

        [URL="http://www.php.net/switch"]switch[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lolFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]]) {
            case[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]:[/COLOR]
                [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Schandaal[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/break"]break[/URL][COLOR= #007700];        
            case[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]:[/COLOR]
                [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Burger[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/break"]break[/URL][COLOR= #007700];            
            case[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]:[/COLOR]
                [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Senaat[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/break"]break[/URL][COLOR= #007700];            
            default:[/COLOR]
                [URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]Keizer[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/break"]break[/URL][COLOR= #007700];
        }
    }[/COLOR]
?>
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo heb ik het nu al, Jponsen. Toch bedankt. smile
0
Berichten
238
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
gratz xd
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren