Could not run query

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

Louise

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
boclair [ So, 28 September 2008 02:48 ] [ ID #1971065 ]

Re: Could not run query

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:<br>$query<br>Error: " . mysql_error());
>
> Louise

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Martin Zvarik [ So, 28 September 2008 12:25 ] [ ID #1971068 ]

Re: Could not run query

--------------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:<br>$query<br>Error: " . mysql_error());
>
> Louise
>

--------------020108080607070708030206--
danaketh [ So, 28 September 2008 13:35 ] [ ID #1971069 ]

Re: Could not run query

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:<br>$query<br>Error: " . mysql_error());
>>
>> Louise
>>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Martin Zvarik [ So, 28 September 2008 13:47 ] [ ID #1971070 ]

Re: Could not run query

> 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
Sandy Keathley [ So, 28 September 2008 14:30 ] [ ID #1971071 ]
PHP » gmane.comp.php.database » Could not run query

Vorheriges Thema: Using oci_execute
Nächstes Thema: Performance (lots of tables / databases...)