gpt4 book ai didi

mysql - 神秘错误1064

转载 作者:行者123 更新时间:2023-11-28 23:19:34 24 4
gpt4 key购买 nike

我正在尝试将一个字符串插入 MySQL 数据库 - 它包含包含引号、星号、反斜杠等的正则表达式 - 以下内容不起作用 - 有没有想过如何更正它?根据其他答案,我也尝试过 htmlentities 但没有任何乐趣。

qa_db_query_sub('INSERT INTO `^islamiqa_topics` (title, description, regexp) VALUES ($, $, $)', $title, $description, mysql_real_escape_string($regexp));

这是我得到的错误:

Database query error 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 'regexp)
VALUES ('7/7', '3rd of March 1924 was the day the Ottoman' at line 1

INSERT INTO `qa_islamiqa_topics` (title, description, regexp) VALUES ('7/7', '3rd of March 1924 was the day the Ottoman Caliphate was formally abolished in Turkey by Mustafa Kemal Atataurk.', '7/7(/2005)?|7(th)? july 2005|july 7.* 2005')

最佳答案

您可以在将字符串添加到数据库之前对其进行 base64_encode()。

qa_db_query_sub('INSERT INTO `islamiqa_topics` (`title`, `description`, `regexp`) VALUES ($, $, $)', $title, $description, base64_encode($regexp));

此外,@Del 发现 regexp 是保留字,因此您不能将其用作表列名。您也可以尝试使用 regexp(添加引号)

关于mysql - 神秘错误1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42415180/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com