0
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
3
Contributors
2
Replies
23
Views
4 Years
Discussion Span
Last Post by broj1
1

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.

0

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.

Edited by broj1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.