Why should they show up in database if you're deleting it right after inserting?

Pavel

On Thu, Nov 12, 2009 at 2:50 PM, perkinsdp
<bren...@designpilotonline.com> wrote:
>
> 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;
> ?>
> --
> View this message in context: 
> http://old.nabble.com/image-upload-to-db-trouble-tp26325178p26325178.html
> Sent from the SQLite mailing list archive at Nabble.com.
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to