On Thu, 12 Nov 2009, perkinsdp wrote:

> To: sqlite-users@sqlite.org
> From: perkinsdp <bren...@designpilotonline.com>
> Subject: [sqlite]  image upload to db trouble
> 
>
> hey guys i have a script where im taking images and uploading to an upload
> file on my server ( this part works fine in my code ) i also want it to put
> the images into my sqlite3 database which has the table images. Im new to
> this and cant seem to figure out why they wont show up in the db.
>
> <?php
>
>  $success = 0;
>  $fail = 0;
>  $uploaddir = '../uploads/';
>  for ($i=0;$i<5;$i++)
>  {
>   if($_FILES['userfile']['name'][$i])
>   {
>    $uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$i]);
>    $ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
>    if (preg_match("/(jpg|gif|png|bmp)/",$ext))
>    {
>     if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i],
> $uploadfile))
>     {
>
>      $success++;
>         $info= $_POST[desc.$i];
>         $images=$uploadfile;
>         $url=$_POST[textfield.$i];
>         //echo $info;
>
>     //echo $images;
>        $db = new PDO('sqlite: database.sqlite3');
>
>        $con = sqlite_open('sqlite: database.sqlite3');
> if (!$con)
>  {
>  die('Could not connect: ' . mysql_error());
>  }
>
>         $db->query('sqlite: database.sqlite3', $con);
>
>         $db->query ("INSERT INTO images (id, images, info, url)
>         VALUES ('$i', '$images', '$info', '$url')");
>
>         $db->query("DELETE FROM images WHERE id='$i'");
> }
>
>     else
>     {
>     echo "Error Uploading the file. Retry after sometime.\n";
>     $fail++;
>     }
>    }
>    else
>    {
>     $fail++;
>    }
>   }
>  }
>  echo "<br> Number of files Uploaded:".$success;
>  echo "<br> Number of files Failed:".$fail;
> ?>
> --

Do you have the create statemnt for your DB please?

Kind Regards,

Keith Roberts

-----------------------------------------------------------------
Websites:
http://www.php-debuggers.net
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-----------------------------------------------------------------
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to