php + mysql query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

php + mysql query

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

01:30:00

is that what you were after?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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());
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why are there no quotes around the time in the output?
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

sorry what do you mean by that?
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

ok i'm with you!!

that seems to have worked, thanks for your help
Post Reply