Search code examples
phpmysqlmysql-error-1064

SQL insert error SQL syntax ... date()


This is the error i'm receiving 1064 - 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 ':i:s a), rec_type = '', rec_request = '1', rec_by = 'Victoria', batch_id = UC' at line 1

also i'm aware that I need to escape before inserting. I'm just testing right now.

$importwav="INSERT into names SET 
com_id = '".$word_id."',
rec_date = date(d-M-y),
rec_time = date(h:i:s a),
rec_type = '".$rec_type."',
rec_request = '1',
rec_by = '".$data[8]."',
batch_id = UCASE('".$batchid."')
";


    INSERT into names SET com_id = '87', rec_date = date(d-M-y), 
rec_time = date(h:i:s a), rec_type = '', rec_request = '1', 
rec_by = 'Victoria', batch_id = UCASE('Batch004AM')

Solution

  • You're confusing your PHP functions and your MySQL functions.

    $importwav="INSERT into names SET 
    com_id = '".$word_id."',
    rec_date = '" . date('d-M-y') . "',
    rec_time = '" . date('h:i:s a') . "',
     ...
    

    And your SQL syntax is FUBAR.