【问题标题】:what error in SQL syntaxSQL语法有什么错误
【发布时间】:2015-04-02 15:44:41
【问题描述】:

这个错误是什么意思:

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取正确的语法以使用 near times new roman;字体大小:x-large;颜色:#a67859;> 在第 1 行

查询

 update page set en_title = 'Team', 
  en_content = ' Jasmine Low Sales & Marketing Manager (Singapore) ', image_1 = 'Shirley.jpg',

image_2 = 'Jessica.jpg', keyword = 'test', description = '' where id_page = '3'

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 'times new roman'; font-size: x-large;">Cheryl Koh

【问题讨论】:

  • 请发布查询
  • 请在问题中也添加您的 SQL 查询!
  • 它是第 1 行,检查那里有什么。
  • 可能只是错误或缺少引号...
  • 当我提交高于 sql 错误显示的数据时,我正在通过 ck-editor 提交带有文本输入的表单。请给我解决方案

标签: php mysql sql


【解决方案1】:

您的查询:

update page
set en_title = 'Team',
    en_content = ' Jasmine Low Sales & Marketing Manager (Singapore) ',
    image_1 = 'Shirley.jpg',
    image_2 = 'Jessica.jpg',
    keyword = 'test',
    description = ''
where id_page = '3'

是正确的,但您的 SQL 脚本或您运行 SQL 脚本的方式包含错误。

如果您的错误来自包含短语“'times new roman'; font-size: x-large;”的 en_content那么你最好使用prepared statement 而不是将任意字符串与你的 SQL 连接起来(这可能会导致 SQL 注入)。

PREPARE stmt1 FROM 'update page
set en_title = ?,
    en_content = ?,
    image_1 = ?,
    image_2 = ?,
    keyword = ?,
    description = ?
where id_page = ?';

set @en_title = 'Team';
set @en_content = ' Jasmine Low Sales & Marketing Manager (Singapore) ';
set @image_1 = 'Shirley.jpg';
set @image_2 = 'Jessica.jpg';
set @keyword = 'test';
set @description = '';
set @id_page = '3';

EXECUTE stmt1 USING @en_title, @en_content, @image_1, @image_2, @keyword, @description, @id_page;

【讨论】:

  • 在上面的查询中 en_content 的字段数据显示的是简单的文本,这里没有显示完整的内容,但是 en_content 字段的 HTML 数据来自 ck-editor。
猜你喜欢
  • 1970-01-01
  • 2019-07-24
  • 2015-02-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-28
  • 2020-01-18
  • 1970-01-01
相关资源
最近更新 更多