Bentley4 Posted May 21, 2011 Share Posted May 21, 2011 Hi guys! I inputted text into the field 'TSuperQuestion' of my table. Now I am trying to echo that text. I get the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /webusers/ph6theo/public_html/Code-sandbox.php This is my code: <?PHP $con = mysql_connect("localhost","ph6theo", "xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ph6theo_testDB") or die(mysql_error()); $result = mysql_query("SELECT * FROM Q&ATable"); $row = mysql_fetch_array($result); echo $row['TSuperQuestion']; ?> Can anyone help? Link to comment https://forums.phpfreaks.com/topic/237045-mysql_fetch_array-error/ Share on other sites More sharing options...
otuatail Posted May 21, 2011 Share Posted May 21, 2011 first off get rid of or die(mysql_error()) or replace with or die(mysql_error("oops")) don't want hackers getting you secret information. Can you get to the database directly with something like phpMyAdmin and test SELECT * FROM Q&ATable directly. Do you realy want all (*) Desmond. Link to comment https://forums.phpfreaks.com/topic/237045-mysql_fetch_array-error/#findComment-1218416 Share on other sites More sharing options...
otuatail Posted May 21, 2011 Share Posted May 21, 2011 Sorry shouldent have said get rid of. But replace with. Link to comment https://forums.phpfreaks.com/topic/237045-mysql_fetch_array-error/#findComment-1218418 Share on other sites More sharing options...
PFMaBiSmAd Posted May 21, 2011 Share Posted May 21, 2011 & is a special character and cannot be used in a database, table, or column name unless you enclose the database, table, or column name in back-ticks `` Link to comment https://forums.phpfreaks.com/topic/237045-mysql_fetch_array-error/#findComment-1218421 Share on other sites More sharing options...
otuatail Posted May 21, 2011 Share Posted May 21, 2011 Yes. I didn't know about the illigal & some DBs do, but testing the query directly would have revealed this. Link to comment https://forums.phpfreaks.com/topic/237045-mysql_fetch_array-error/#findComment-1218422 Share on other sites More sharing options...
Bentley4 Posted May 21, 2011 Author Share Posted May 21, 2011 Changed it and it works. Thnx PFMaBiSmAd! Link to comment https://forums.phpfreaks.com/topic/237045-mysql_fetch_array-error/#findComment-1218426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.