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

发布于 2024-10-07 02:30:46 字数 611 浏览 0 评论 0原文

这是我收到的错误 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的 ':i:sa)、rec_type = ''、rec_request = '1'、rec_by = 'Victoria'、batch_id = UC' 附近使用的正确

语法我知道我需要在插入之前转义。我现在只是在测试。

$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')

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')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟花易冷人易散 2024-10-14 02:30:46

您混淆了 PHP 函数和 MySQL 函数。

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

你的 SQL 语法是 FUBAR。

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.

姜生凉生 2024-10-14 02:30:46

SQL 语法不正确。

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

Improper SQL syntax.

INSERT INTO table (col1, col2) VALUES (val1, val2)
总以为 2024-10-14 02:30:46

date() 参数必须是字符串。尝试用单引号 (') 括住日期格式字符串。

date() arguments need to be a string. Try surrounding your date format strings with single quotes (').

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文