title: Upload Image to database using PHP
body: <p>I need help uploading pictures to my database, in Sequel Pro. This is the HTML code in order to run the PHP script once the user has pressed the "Submit" button:</p>
  
  <pre><code>&lt;form action="/Alesh_New_Website/saveImg.php" method="POST"   enctype="multipart/form-data"&gt;
  &lt;input type="file" name="image"&gt;
  &lt;input type="submit" name="submit" value="Upload"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is the PHP code:
      
  
  <pre><code>$servername = "localhost"; 
  $username = "root";
  $password = "root";
  $dbname = "IMGSTORAGE";
  
  try{
  $conn = new PDO("mysql:host=$servername; dbname=$dbname", $username, $password);
  $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  $name = addslashes($_FILES['image']['name']);
  $image = addslashes($_FILES['name']['tmp_name']);
  $image = file_get_contents($image);
  $image = base64_encode($image);
  $sql = "INSERT INTO 'STOREDIMG' ('name', 'image') VALUES ('$name, $image')";
  
  $conn-&gt;exec($sql);
  echo "Image uploaded";
  }
  catch (PDOException $e){
  echo "Connection Failed: " . $e-&gt;getMessage();  
  }
  
  ?&gt;
  </code></pre>
  
  <p>I was watching videos in order to create this PHP statement; I barely know about PHP, but I want to learn it at its fullest. I need a way to make this work, since every time I run it, I get this error:</p>
  
  <blockquote>
    <p><strong>"Connection Failed: 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 ''STOREDIMG' ('name', 'image') VALUES ('Image_Name.jpg, ')'
    at line 1"</strong></p>
  </blockquote>
  
  <p>Is there any way I can fix this or make it work in order to serve the purpose I want? I appreciate your help. Thank you.</p>