PHP MySQL Syntax Error 'You have an error in your SQL syntax'

Posted by Alec on Stack Overflow See other posts from Stack Overflow or by Alec
Published on 2012-10-04T03:18:14Z Indexed on 2012/10/04 3:37 UTC
Read the original article Hit count: 177

Filed under:
|
|
|

I cannot figure out the issue with my code here. I am trying to take info from the table, then subtract 1 second from Current_Time which looks like '2:00'. The problem is, I get:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Current_Time) VALUES('22')' at line 1"

I don't even understand where it gets 22 from.

Thanks, I really appreciate it.

if (isset($_GET['id']) && isset($_GET['time'])) {
    mysql_select_db("aleckaza_pennyauction", $connection);
    $query = "SELECT Current_Time FROM Live_Auctions WHERE ID='1'";
    $results = mysql_query($query) or die(mysql_error());

    while ($row = mysql_fetch_array($results)) {
        $newTime = $row['Current_Time'] - 1;
        $query = "INSERT INTO Live_Auctions(Current_Time) VALUES('".$newTime."')";
        $results = mysql_query($query) or die(mysql_error());
    }
}

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql