...

View Full Version : Please help, a PHP MySQL syntax error



markbaron15
07-22-2012, 07:05 AM
I just want to ask if anything wrong with my query?

im using
MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $
and PHP Version 5.3.5

[CODE]
if (!executeQuery("insert into studenttest values(" . $_SESSION['stdid'] . "," . $_SESSION['testid'] . ",(select CURRENT_TIMESTAMP),date_add((select CURRENT_TIMESTAMP),INTERVAL (select duration from test where testid=" . $_SESSION['testid'] . ") MINUTE),0,'inprogress')"))
[CODE]

it still gives me an error
"errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1)),(select CURRENT_TIMESTAMP),date_add((select CURRENT_TIMESTAMP),INTERVAL (sel' at line 1"

Im inserting a stdid(a primary key from table `users`) into table `studenttest`.

Please help.

HDRebel88
07-22-2012, 07:10 AM
I just want to ask if anything wrong with my query?

im using
MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $
and PHP Version 5.3.5

[CODE]
if (!executeQuery("insert into studenttest values(" . $_SESSION['stdid'] . "," . $_SESSION['testid'] . ",(select CURRENT_TIMESTAMP),date_add((select CURRENT_TIMESTAMP),INTERVAL (select duration from test where testid=" . $_SESSION['testid'] . ") MINUTE),0,'inprogress')"))
[CODE]

it still gives me an error
"errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1)),(select CURRENT_TIMESTAMP),date_add((select CURRENT_TIMESTAMP),INTERVAL (sel' at line 1"

Im inserting a stdid(a primary key from table `users`) into table `studenttest`.

Please help.

You shouldn't need to use SELECT to insert the current timestamp, CURRENT_TIMESTAMP alone should do it.

markbaron15
07-22-2012, 08:13 AM
You shouldn't need to use SELECT to insert the current timestamp, CURRENT_TIMESTAMP alone should do it.

Thanks. I changed it into

if (!executeQuery("insert into studenttest values(" . $_SESSION['stdid'] . "," . $_SESSION['testid'] . ",(CURRENT_TIMESTAMP),date_add(CURRENT_TIMESTAMP),INTERVAL (select duration from test where testid=" . $_SESSION['testid'] . ") MINUTE),0,'inprogress')"))


Hmm. but I still got the error message. I think it is about my php syntax? isn't it?

markbaron15
07-22-2012, 11:04 AM
Btw Thanks @HDRebel88, i got it working now. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum