Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Please help, a PHP MySQL syntax error

    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.

  • #2
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by markbaron15 View Post
    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.

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HDRebel88 View Post
    You shouldn't need to use SELECT to insert the current timestamp, CURRENT_TIMESTAMP alone should do it.
    Thanks. I changed it into
    Code:
    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?
    Last edited by markbaron15; 07-22-2012 at 09:16 AM.

  • #4
    New Coder
    Join Date
    May 2012
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Btw Thanks @HDRebel88, i got it working now. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •