我在尝试将数据插入数据库时收到以下错误。
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/