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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.