-1

I am using the following sql query to upload a image into the database...

$query_upload="INSERT into 'images_tbl' ('images_path','submission_date')    VALUES ('".$target_path."','".date("Y-m-d")."')";
 mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error()); 

But getting and 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 ''images_tbl' ('images_path','submission_date') VALUES ('images/25-10-201' at line 1

Can any body help me to fix the bug?

2 Answers2

0

Tables in mysql are escaped with backticks, not quotes. So use this instead:

$query_upload="INSERT into `images_tbl` (`images_path`,`submission_date`)    VALUES ('".$target_path."','".date("Y-m-d")."')";

See also Should I use backticks or not when escaping keywords in MySQL?

Community
  • 1
  • 1
Sjon
  • 4,989
  • 6
  • 28
  • 46
0

Try this:

$query_upload="INSERT into `images_tbl` (`images_path`,`submission_date`)    VALUES ('".$target_path."','".date("Y-m-d")."')";

table and columns names surrounded by backticks ` not single qoute '

Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47