SocomNegotiator Posted April 16, 2008 Share Posted April 16, 2008 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? Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted April 16, 2008 Share Posted April 16, 2008 this line: $ladders=mysql_query("SELECT id,name FROM ladders game=".$ladderg['game']." ORDER BY name"); makes no sense, you are suppose to have the word "WHERE" between ladders and game Quote Link to comment Share on other sites More sharing options...
SocomNegotiator Posted April 16, 2008 Author Share Posted April 16, 2008 Yeah sorry when I copied and pasted I accidentally took it out some how, but I had that in and it still does not work. Quote Link to comment Share on other sites More sharing options...
psychowolvesbane Posted April 16, 2008 Share Posted April 16, 2008 Try mysql_fetch_array() instead of mysql_fetch_row. Quote Link to comment Share on other sites More sharing options...
SocomNegotiator Posted April 16, 2008 Author Share Posted April 16, 2008 Here was the problem...I need to just use this query instead of the other one SELECT id,name FROM ladders WHERE game = '".$ladderg['game']."' ORDER BY name Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.