Jump to content

[SOLVED] Simple php query problem


SocomNegotiator

Recommended Posts

Ok this does not make sense...here is the code that does not work.

 

$ladder_game=mysql_query("SELECT * FROM ladders WHERE id=".$ladder_url);
$ladderg=mysql_fetch_assoc($ladder_game);

$ladders=mysql_query("SELECT id,name FROM ladders game=".$ladderg['game']." ORDER BY name");
while(list($id,$name)=mysql_fetch_row($ladders)){
$ladderlist.="<option value='$id'>$ladders[game]$name</option>\n";
}

I get this error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result

 

Now get this I know that $ladderg['game'] works because when I insert it into the echo I get the game. However, check out the code below it works and the only thing I do is take out game=".$ladderg['game']." from the query and it works fine.

 

$ladder_game=mysql_query("SELECT * FROM ladders WHERE id=".$ladder_url);
$ladderg=mysql_fetch_assoc($ladder_game);

$ladders=mysql_query("SELECT id,name FROM ladders ORDER BY name");
while(list($id,$name)=mysql_fetch_row($ladders)){
$ladderlist.="<option value='$id'>$ladderg[game]$ladders[game]$name</option>\n";
}

 

Now you see that I took out that part in the query, but I stuck it down in the <option> and it works fine. Does anyone have any idea why the top code does not work?

Link to comment
https://forums.phpfreaks.com/topic/101455-solved-simple-php-query-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.