rhodges26 Posted June 27, 2008 Share Posted June 27, 2008 Im getting an error in my database when i try to run a query to grab data, the data is there. I am creating an php to grab information from the database and submit to a webpage, and getting an error. $result = mysql_query("SELECT * FROM Cobalt_Contact"); EMPTY!Firstname Lastname Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/table.php on line 28 I run this right after my query and get empty if ($result){ echo "DATA"; }else{ echo "EMPTY!"; } Here the statement I run in myphpadmin and i get this, SELECT * FROM `Cobalt_Contact` WHERE 1 LIMIT 0 , 30 Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 LIMIT 0, 30 is probably not what you mean... the syntax is LIMIT <number>, <offset>. You're always getting zero rows back. Quote Link to comment Share on other sites More sharing options...
rhodges26 Posted June 27, 2008 Author Share Posted June 27, 2008 Even though i just use this SELECT * FROM `Cobalt_Contact` i get zero rows back, even without the limit statement Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 27, 2008 Share Posted June 27, 2008 Your query is failing and it has no error checking to tell you why. If the query works in phpmyadmin, that would mean that either you don't have a valid connection to the database server or you have not selected a database. Try this to get mysql/php to tell you why the query failed - $result = mysql_query("SELECT * FROM Cobalt_Contact") or die("Query failed: " . mysql_error()); Quote Link to comment Share on other sites More sharing options...
rhodges26 Posted June 27, 2008 Author Share Posted June 27, 2008 Thanks for the help man i got it fixed 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.