php - 使用 MySQL 和 PHP 将数据插入数据库时​​出现 SQL 错误

标签 php mysql

我在尝试将数据插入数据库时​​收到以下错误。

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 'Live Your Life Well'. Live Your Life Well' was a theme designed to encourage peo' at line 1

我提供以下查询:

INSERT phr_health_care set title='Mental Health Awareness',description='In 2010, the theme was 'Live Your Life Well'. Live Your Life Well' was a theme designed to encourage people to take responsibility for the prevention of mental health issues during times of personal challenge and stress. The message was to inform the public that many mental health problems could be avoided by striving toward and making positive lifestyle choices in the ways we act and think',status='1',image='4o2kgkpgu_awarenessdaycolorgen.jpg',date='2016-02-12 15:32:44'

如何解决此错误?

最佳答案

如果插入则

INSERT INTO table_name("column_names_separates_by_commas") VALUES ("values_for_columns_separated_by_commas");

如果更新则

UPDATE table_name SET column1="value1", column2="vaule2", columnN="valueN"

但是下面的 SQL 也执行得很好。

INSERT phr_health_care set 
title='Mental Health Awareness',
description="In 2010, the theme was 'Live Your Life Well'. Live Your Life Well' was a theme designed to encourage people to take responsibility for the prevention of mental health issues during times of personal challenge and stress. The message was to inform the public that many mental health problems could be avoided by striving toward and making positive lifestyle choices in the ways we act and think",
status='1',
image='4o2kgkpgu_awarenessdaycolorgen.jpg',
date='2016-02-12 15:32:44'

这是我自己测试的精确查询,它执行得很好。

关于php - 使用 MySQL 和 PHP 将数据插入数据库时​​出现 SQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35359859/

相关文章:

php - 使用 calibre 进行 EPUB 到 PDF 转换时出现错误

php - 如何将 BitmapData 对象直接上传到我的服务器?

mysql - 在MY SQL中按不同的其他表ID排序

php - 如何自动增加mysql id

mysql - 加载数据输入错误代码 : 13

php - 是否可以将 AngularJS、HTML5 和 CSS3 组合为前端,将 NodeJS 组合为后端,将 PHP5 组合为 rest web 服务?

php - 成员变量不接受包含元素的数组

php - 静态方法比非静态方法快吗?

php - 我需要 DROP TABLE IF EXISTS 然后 CREATE TABLE 然后 LOAD DATA LOCAL INFILE

php - Laravel 计算最重复的项目