Could not run query
am 28.09.2008 02:48:55 von boclair
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:
$query
Error: " . mysql_error());
Louise
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Could not run query
am 28.09.2008 12:25:53 von Martin Zvarik
Have you tested this SQL query?
Insert it into phpmyadmin, does it work?
If it does => php error.
If it doesn't => mysql error.
boclair napsal(a):
> 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:
$query
Error: " . mysql_error());
>
> Louise
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Could not run query
am 28.09.2008 13:35:06 von danaketh
--------------020108080607070708030206
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Well, seems to me like a problem with quotes you're using in query...
The ` quotes you're using doesn't work, when I tried to use them in PHP
called query. Maybe you should try use single quotes and if they works.
boclair napsal(a):
> 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:
$query
Error: " . mysql_error());
>
> Louise
>
--------------020108080607070708030206--
Re: Could not run query
am 28.09.2008 13:47:05 von Martin Zvarik
The quotes are OK.
Tested - works.
danaketh napsal(a):
> Well, seems to me like a problem with quotes you're using in query...
> The ` quotes you're using doesn't work, when I tried to use them in PHP
> called query. Maybe you should try use single quotes and if they works.
>
> boclair napsal(a):
>> 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:
$query
Error: " . mysql_error());
>>
>> Louise
>>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Could not run query
am 28.09.2008 14:30:30 von Sandy Keathley
> 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:
$query
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