forumnz Posted December 8, 2007 Share Posted December 8, 2007 <?php $con = mysql_connect("localhost","aaa","aaa"); if (!$con) { die('Could not connect: ' . mysql_error()); } $id = "127"; $query = "SELECT title FROM 'help' WHERE 'id'=$id"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['title']; } mysql_close($con); ?> Gets me: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /httpdocs/clients/page.php on line 59 How do I fix it? Thanks, Sam. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Change $result = mysql_query($query); to $result = mysql_query($query) OR die ("Error in query: $query. " . mysql_error()); and post the error Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 8, 2007 Share Posted December 8, 2007 try this: <?php $con = mysql_connect("localhost","aaa","aaa"); if (!$con) { die('Could not connect: ' . mysql_error()); } $id="127"; $query = "SELECT title FROM help WHERE id='$id'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['title']; } mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
forumnz Posted December 8, 2007 Author Share Posted December 8, 2007 That didn't work phpQuestioner. Thanks though. This is the error I got: Error in query: SELECT title FROM 'help' WHERE 'id'=127. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''help' WHERE 'id'=127' at line 1 Thanks. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 put help in back ticks `help` Quote Link to comment Share on other sites More sharing options...
forumnz Posted December 8, 2007 Author Share Posted December 8, 2007 Thanks - it works! ;D Sam. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Thats because it's a reserved word. Mark as solved if all is well 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.