Genesis730 Posted January 22, 2010 Share Posted January 22, 2010 I posted this a little bit ago, and was told to change a row field from "primary" to something else since primary is a key word... here is my updated code, i still get the same error... "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource" <table cellspacing="0" cellpadding="0" border="1"> <tr> <td>ID</td><td>Name</td><td>Primary #</td><td>Secondary #</td><td>Address</td><td>City</td><td>Arizona</td><td>ZIP</td><td>Email Address</td><td>Diagnostic</td><td>Virus</td><td>Optimize</td><td>Repair</td><td>Setup</td><td>OS</td><td>Backup</td><td>Questions</td><td>Miles</td><td>Paid</td> </tr> <?PHP $res = mysql_query("SELECT id, date, firstname, lastname, primaryphone, secondaryphone, address, city, state, zip, emailaddress, diagnostic, virus, optimize, repair, setup, os, backup, questions, miles, paid FROM contact ORDER BY date"); while ($row = mysql_fetch_assoc($res)) { echo "<tr><td>{$row['id']}</td><td>{$row['firstname']} {$row['lastname']}</td><td>{$row['primaryphone']}</td><td>{$row['secondaryphone']}</td><td>{$row['address']}</td><td>{$row['city']}</td><td>{$row['state']}</td><td>{$row['zip']}</td><td>{$row['emailaddress']}</td><td>{$row['diagnostic']}</td><td>{$row['virus']}</td><td>{$row['optimize']}</td><td>{$row['repair']}</td><td>{$row['setup']}</td><td>{$row['os']}</td><td>{$row['backup']}</td><td>{$row['questions']}</td><td>{$row['miles']}</td><td>{$row['paid']}</td></tr>"; } ?> </table> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 22, 2010 Share Posted January 22, 2010 Change your query so that it has the or die(trigger_error()); after it (temporarily) and post back the result. $res = mysql_query("SELECT id, date, firstname, lastname, primaryphone, secondaryphone, address, city, state, zip, emailaddress, diagnostic, virus, optimize, repair, setup, os, backup, questions, miles, paid FROM contact ORDER BY date") or trigger_error(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Genesis730 Posted January 22, 2010 Author Share Posted January 22, 2010 I did what you suggested Andy-H and got this error "Notice: 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 'optimize, repair, setup, os, backup, questions, miles, paid FROM contact ORDER B' at line 1" $res = mysql_query("SELECT id, date, firstname, lastname, primaryphone, secondaryphone, address, city, state, zip, emailaddress, diagnostic, virus, optimize, repair, setup, os, backup, questions, miles, paid FROM contact ORDER BY date"); WAS CHANGED TO $res = mysql_query("SELECT id, date, firstname, lastname, primaryphone, secondaryphone, address, city, state, zip, emailaddress, diagnostic, virus, optimize, repair, setup, os, backup, questions, miles, paid FROM contact ORDER BY date") or trigger_error(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 22, 2010 Share Posted January 22, 2010 Sorry, beers getting to me lol I meant append or trigger_error(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Genesis730 Posted January 22, 2010 Author Share Posted January 22, 2010 Oh, I wrote it wrong, the new error is "Notice: 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 'optimize, repair, setup, os, backup, questions, miles, paid FROM contact' at line 1" Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 22, 2010 Share Posted January 22, 2010 http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html Looks like optimize is a mysql keyword, add the backticks (`) around the fieldname in your query as shown in the code below or change the table name. $res = mysql_query("SELECT id, date, firstname, lastname, primaryphone, secondaryphone, address, city, state, zip, emailaddress, diagnostic, virus, `optimize`, repair, setup, os, backup, questions, miles, paid FROM contact ORDER BY date") or trigger_error(mysql_error()); 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.