the page show
Error: 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 'test2','test3')' at line 3

my php code

<?php


require 'config.php';

 // Insert data into mysql 
 $sql="INSERT INTO content (title , discription,  content)
 VALUES
 ('$_POST[title]',''$_POST[discription]','$_POST[content]')";

 if (!mysql_query($sql,$con))
   {
   die('Error: ' . mysql_error());
   }
 echo "1 record added",


mysql_close($con);
 ?> 

my sql code :

CREATE TABLE  `matancms`.`content` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` TINYTEXT NOT NULL ,
`discription` TINYTEXT NOT NULL ,
`catid` TINYTEXT NOT NULL ,
`content` TEXT NOT NULL
) ENGINE = MYISAM

Recommended Answers

Error: 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 'test2','test3')' at line 3

Which is line 3?

You mean this line: require "config.php";?

You can put ( ) parentheses:

require ("config.php"); …
Jump to Post

All 2 Replies

Member Avatar

Error: 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 'test2','test3')' at line 3

Which is line 3?

You mean this line: require "config.php";?

You can put ( ) parentheses:

require ("config.php");

There's an extra single qoute on line 14 which is this ''$_POST[discription]':

('$_POST[title]',''$_POST[discription]','$_POST[content]')";

take it out and it should look like this:

('$_POST[title]','$_POST[discription]','$_POST[content]')";

I think this might solve your issue.

On line 14

('$_POST[title]',''$_POST[discription]','$_POST[content]')";

you have two single quotes so the query syntax is wrong. Remove one of them.

Edit: haven't noticed that LastMitch has already pointed that out, sory.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.