0

I'm trying to send title and content to my table named write . But i'm having error while running this php file .

Below is the error shown

not sucessfullyYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'write values('','','')' at line 1

<?php
 require "connection.php";

 $id = $_POST["id"];
 $title =$_POST["title"];
 $content =$_POST["content"];




 $sql_query ="insert into write values('$id','$title','$content');";


 if(mysqli_query($con,$sql_query))
 {
 echo"data insertion sucess";
 }
else
{
echo "not sucessfully".mysqli_error($con);
}

?>
2
  • As you can see there are no values. Check your form and make sure the data is posted correctly. Also, you should check if data is valid before sql query. Commented Aug 10, 2016 at 10:05
  • just echo the query and find out the actual query Commented Aug 10, 2016 at 10:05

1 Answer 1

3

WRITE is a reserved keyword in MySQL so you should escape it using backticks:

insert into `write` ...

But I would recommend you rename the table into something more sensible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.