Skip to content
Advertisement

Getting SQL error while inserting the data into database using MySQL and PHP

I am getting the following error while trying to insert data into database.

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

I am providing the query below:

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'

How can I resolve this error?

Advertisement

Answer

if insert then

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

if update then

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

but following SQL is also executing fine.

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'

this is exact query i tested by myself and it is executing fine.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement