Am 13.11.2009 um 09:25 schrieb Keith Roberts: > On Fri, 13 Nov 2009, Artur Reilin wrote: > >> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> >> From: Artur Reilin <sql...@yuedream.de> >> Subject: Re: [sqlite] image upload to db trouble >> >>> //echo $images; >>> $db = new PDO('sqlite: database.sqlite3'); >>> >>> $con = sqlite_open('sqlite: database.sqlite3'); >>> if (!$con) >>> { >>> die('Could not connect: ' . mysql_error()); >>> } >> >> why you first make a new db opject and then open an connection to the >> database? new PDO sqlite already open an connection .. as i am right. >> >> and why 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'"); >>> } >> >> AS i know, if you want to put images in your db you need blob >> columns and >> these are supported in sqlite3. or i understand something wrong? > > There's no need to save the actual image in the sqlite > database, as that could slow things like SELECT statements > down. > > Another way is to move the image file to a certain > directory. Then store only the location of the image file in > the sqlite DB. > > If you move the sqlite DB, then just make sure the directory > of images also goes with it.
AFAICS from the original source, this is already what the code is supposed to do: > if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], > $uploadfile)) > { > > $success++; > $info= $_POST[desc.$i]; > $images=$uploadfile; > $url=$_POST[textfield.$i]; > ... > $db->query ("INSERT INTO images (id, images, info, url) VALUES > ('$i', '$images', '$info', '$url')"); > ... > } Thus, $images is just a string containing the path to the moved upload file... However, there's a couple of statements in the code that I don't know what to make of: (1) as pointed out earlier, the DELETE statement removes the record immediately after INSERTing (2) $db = new PDO('sqlite: database.sqlite3'); -> this will attempt to open a connection to the database file "database.sqlite3" in which directory? Did you check that this call succeeded??? You may need to use an absolute path here... (3) $con = sqlite_open('sqlite: database.sqlite3'); -> wouldn't this open just another sqlite database connection via a different mechanism? (4) $db->query('sqlite: database.sqlite3', $con); -> what is this supposed to do? Did you verify that your query calls actually succeeded? I would (a) check that $db != null (b) check that the query calls actually worked (PDO::query() returns a PDOStatement object, or FALSE on failure.) </jum> _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users