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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.