简体   繁体   English

SQL插入错误SQL语法…date()

[英]SQL insert error SQL syntax … date()

This is the error i'm receiving 1064 - You have an error in your SQL syntax; 这是我收到的错误1064-您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near ':i:sa), rec_type = '', rec_request = '1', rec_by = 'Victoria', batch_id = UC' at line 1 检查与您的MySQL服务器版本对应的手册,以便在':i:sa),rec_type ='',rec_request ='1',rec_type ='Victoria',batch_id = UC'在第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')

You're confusing your PHP functions and your MySQL functions. 您的PHP函数和MySQL函数令人困惑。

$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. 您的SQL语法是FUBAR。

SQL语法不正确。

INSERT INTO table (col1, col2) VALUES (val1, val2)

date() arguments need to be a string. date()参数必须为字符串。 Try surrounding your date format strings with single quotes ( ' ). 尝试用单引号( ' )括住日期格式字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM