title: PHP Upload image to mysql database using PDO?
body: <p>I have a database set up and am trying to upload an image to it. The database is called 'blob' and has 3 fields. id, name and image, with image set as blob. When trying to upload the image i get an error that i am unsure of. Below is my code.</p>
  
  <pre><code>&lt;?php
  include ("dbConnect.php");
  ?&gt;
  
  &lt;form action="imageuploadtest.php" enctype="multipart/form-data" method="post"&gt;
  &lt;input name="image" type="file"&gt;&lt;input name="submit" type="submit" value="Upload"&gt;
  &lt;/form&gt;
  
  &lt;?php 
  
  if(isset($_POST['submit']))
  {
  
    $imageName = $_FILES["image"]["name"];
    $imageData = file_get_contents($_FILES["image"]["tmp_name"]);
    $imageType = $_FILES["image"]["type"];
  
    if(substr($imageType,0,5)=="image")
    {
       $dbQuery = $db-&gt;prepare("INSERT INTO blob ( name, image) VALUES ('$imageName', '$imageData')");
       $dbQuery-&gt;execute();
    }
    else
    {
     echo "only images are allowed";
    } 
  }
  ?&gt;
  </code></pre>
  
  <p>The database connection is fine, but i get the following error message that i am usure of how to fix.</p>
  
  <pre><code> Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters' in N:\ftp\compc\d12ac1\FlightsFromNI\imageuploadtest.php:23 Stack trace: #0 N:\ftp\compc\d12ac1\FlightsFromNI\imageuploadtest.php(23): PDO-&gt;prepare('INSERT INTO blo...') #1 {main} thrown in N:\ftp\compc\d12ac1\FlightsFromNI\imageuploadtest.php on line 23.
  </code></pre>
  
  <p>Any help would be appreciated. Thanks.</p>
  
  <p>EDIT: Have now changed my table name from blob to imgupload but still get the same error message?</p>