Jump to content

[SOLVED] mysql database


rhodges26

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/112193-solved-mysql-database/
Share on other sites

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());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.