Re: Could not run query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I need help to track down the cause of the error,"Could not run query"
> 
> A typical query is
> 
> $laterrecords = mysql_query("SELECT * FROM messages WHERE `logged` > 
> $timebegin ORDER BY `logged` DESC" ) or die ("Cannot 
> select:<br>$query<br>Error: " . mysql_error());


Try putting single quotes around $timebegin.  If $timebegin is not a 
Unix timestamp, you can also use the DATE functions in MySQL,

A good way to debug these problems is to always put the query in a 
separate variable

$query = "SELECT * FROM messages ..."
//echo $query;
//exit;
$laterrecords = mysql_query($query);

Then echo the actual interpolated query to the screen, copy it, and 
run it manually in a query tool (phpMyAdmin, 
MySQLQueryBrowser, or similar).

The query tool will tell you where the error is.


SK



--
Sandy Keathley
Zend Certified Engineer
Senior Programmer
The Dent Zone Companies, Inc.
214-393-2228



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux