runthis Posted October 2, 2010 Share Posted October 2, 2010 ok im fairly good at php and for an HOUR i cant figure out my typo in this f*ck*ng shortest page ever $get=$_GET['id']; $qd2=mysql_query("SELECT to FROM newgamechat WHERE to='{$get}'"); while($rd2=mysql_fetch_array($qd2)){ print $rd2[to]; } When i change the "to" to anything else at all it works fine SELECT to FROM newgamechat WHERE id='{$get}'"); WTF am i dong wrong? The error is Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Quote Link to comment https://forums.phpfreaks.com/topic/214978-what-the-f/ Share on other sites More sharing options...
kenrbnsn Posted October 2, 2010 Share Posted October 2, 2010 Are you getting an error? If so, show us the error? Do you have a field in your database called "to"? Ken Quote Link to comment https://forums.phpfreaks.com/topic/214978-what-the-f/#findComment-1118287 Share on other sites More sharing options...
Maq Posted October 2, 2010 Share Posted October 2, 2010 'to' is a reserved MySQL keyword. http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html You either need to change it to something else or put backtics `to` around it wherever it's used. Quote Link to comment https://forums.phpfreaks.com/topic/214978-what-the-f/#findComment-1118288 Share on other sites More sharing options...
runthis Posted October 2, 2010 Author Share Posted October 2, 2010 Son of a b. i knew it was something utterly retarded, thats why it wouldnt let me use the from field either, right on, topic closed Quote Link to comment https://forums.phpfreaks.com/topic/214978-what-the-f/#findComment-1118289 Share on other sites More sharing options...
Yesideez Posted October 2, 2010 Share Posted October 2, 2010 I got into the habit of using backticks right from the start. Not a bad thing as I think it makes queries slightly more readable. Quote Link to comment https://forums.phpfreaks.com/topic/214978-what-the-f/#findComment-1118300 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.