Page 1 of 1

php + mysql query

Posted: Mon Aug 15, 2005 10:41 am
by hame22
Hi

I am trying to perform a mysql query through a php page.

The query involves querying a time type field in my database 00:00:00

The value it is queried by is recieved from a value from a drop down list.

I have used the following query:

Code: Select all

mysql_query("Select * from activities where learn_time > '$start_time'");

where $start_time is represented by a value in the following format 00:00:00 e.g. 03:00:00

but I get a query error :

You have an error in your SQL syntax near ':00:00' at line 1

any ideas what is wrong do I need to specify that the value is a time format or something??

thanks

alex

Posted: Mon Aug 15, 2005 10:43 am
by feyd
echo the query string you're passing to mysql and post it. It sounds like you aren't quoting, or are quoting improperly the stamp.

Posted: Mon Aug 15, 2005 10:46 am
by hame22
01:30:00

is that what you were after?

Posted: Mon Aug 15, 2005 10:48 am
by feyd
no, this:

Code: Select all

$sql = "Select * from activities where learn_time > '$start_time'";
echo $sql;
$query = mysql_query($sql) or die(mysql_error());

Posted: Mon Aug 15, 2005 10:53 am
by hame22
"SELECT * FROM activities WHERE learn_time > 03:00:00"

You have an error in your SQL syntax near ':00:00' at line 1

Posted: Mon Aug 15, 2005 11:00 am
by feyd
why are there no quotes around the time in the output?

Posted: Tue Aug 16, 2005 3:28 am
by hame22
sorry what do you mean by that?

Posted: Tue Aug 16, 2005 3:32 am
by hame22
ok i'm with you!!

that seems to have worked, thanks for your help