UtamaBeritaTutorialBlogTool



What caused an error in mysql query?

$query = mysql_query("SELECT * FROM table WHERE table_id = 1", $db);
$content = mysql_fetch_object($query);

The above command will execute the query using the mysql_query(). $query will be true if the query is successfully executed or it will return false. But if the error occured, it just show the arguement is not a valid MySQL result. Use the mysql_error() function to find out what is the real error was:

$query = mysql_query("SELECT * FROM table WHERE table_id = 1", $db)
or die (”Query failed: ” . mysql_error() . ” Actual query: ” . $query);
$content = mysql_fetch_object($query);

Technorati Tags:

No Comments


Leave a reply

= Please answer this math (required)