将图像上传到数据库时出错

I want to upload an image to a database.

First I created a form and tried to upload image into database. I also created database and table and image folder where I want to load image. But I get the following error:

error in INSERT into images_tbl ('images_path','submission_date') VALUES ('images/24-01-2015-1422097448.jpg','2015-01-24') == ----> 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_path','submission_date') VALUES ('images/24-01-2015-1422097448.jpg' at line 1

What am I doing wrong?

Form section to upload image:

<html>
 <body>
  <form action="saveimage.php" enctype="multipart/form-data" method="post">

   <table style="border-collapse: collapse; font: 12px Tahoma;" border="1" cellspacing="5" cellpadding="5">
    <tbody><tr>
      <td>
      <input name="uploadedimage" type="file">
      </td>

     </tr>

     <tr>
      <td>
      <input name="Upload Now" type="submit" value="Upload Image">
      </td>
     </tr>

   </tbody></table>

  </form>
 </body>
</html>

Code section to insert image image to database:

<?php

  $con=mysql_connect("localhost","root","");
  if(!$con)
  {
    die('could not connect'.mysql_error());
  }
  mysql_select_db("image",$con) or die(mysql_error());

  function GetImageExtension($imagetype)
  {
    if(empty($imagetype)) return false;
    switch($imagetype)
    {
      case 'image/bmp':  return '.bmp';               
      case 'image/gif':  return '.gif';
      case 'image/jpeg': return '.jpg';
      case 'image/png':  return '.png';
      default: return false;
    }
  }

  //Here I try to upload the selected image 

  if (!empty($_FILES["uploadedimage"]["name"])) {

    $file_name=$_FILES["uploadedimage"]["name"];
    $temp_name=$_FILES["uploadedimage"]["tmp_name"];
    $imgtype=$_FILES["uploadedimage"]["type"];
    $ext= GetImageExtension($imgtype);
    $imagename=date("d-m-Y")."-".time().$ext;
    $target_path = "images/".$imagename;


    if(move_uploaded_file($temp_name, $target_path)) {

      $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()); 

    }else{

      exit("Error While uploading image on the server");
    }

  }

?>

Try to Use ` backticks for MYSQL reserved words.

your query should be as follows.

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

your error occur in ' quote between table name and field name. the query should be

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

try this :

Replace '' with `` in table name and column name.

Use

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

instead of

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