Jump to content
Sign in to follow this  


Recommended Posts

when I am inserting normal text (without "/ . , ; ') php is succesfully uploading my data, but if my text contains these characters: /./,;; php is sending this following error



SQLSTATE[42000]: Syntax error or access violation: 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 '['['')' at line 2 ,




what does it mean and how to overcome it?

Share this post

Link to post
Share on other sites

I'd need to see your full SQL query to know what the problem is. It's a syntax error in your SQL.

  • Like 1

Share this post

Link to post
Share on other sites

here is my full source code:

<!DOCTYPE html>



<title>uploading a file</title>


<body bgcolor="blue">

<form method="post">

<table align="center" width="700" border="2" bgcolor="green">

<tr align="center">

<td align="center">

<td colspan="8"><h2>upload whatever you want mr Alfraganus</h2></td>



<td colspan="8" align="center"><input type="text" name="title" size="60"><b>Title</b></td>



<td colspan="8"><textarea name="body" cols="80" rows="20"></textarea></td>



<td colspan="8"><center><input type="submit" name="upload" value="upload the text"> </center></td>






if (isset($_POST['upload'])) {





try {

$dbh=new PDO("mysql:host=$hostname;dbname=$db_name", $username,$password);


$sql= "INSERT INTO tables (title, body)

values ('".$_POST["title"]."','".$_POST["body"]."')";




$sth->bindvalue(':title', $title, PDO::PARAM_STR);

$sth->bindvalue(':body', $body, PDO::PARAM_STR);




catch (PDOexception $e)


echo $e->getMessage();



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this