Shambles Posted July 23, 2009 Share Posted July 23, 2009 Hi, I try to insert an image into a sqlite2 table, but every time i get this error message: Warning: sqlite_exec() [function.sqlite-exec]: unrecognized token: "#" in \var\www\localhost\htdocs\upload\index.php on line 4 Error in query: 'unrecognized token: "#"' Here is the code: $fileContent=file_get_contents($_FILES['image']['tmp_name'],FILE_TEXT); $fileContent=sqlite_escape_string($fileContent); $dbhandle = sqlite_open('image.sqlite'); $query = sqlite_exec($dbhandle, 'INSERT INTO image VALUES ("'.$_FILES['image']['type'].'","'.$fileContent.'")', $error); if (!$query) { exit("Error in query: '$error'"); } else { echo 'Number of rows modified: ', sqlite_changes($dbhandle); } My interim solution at the moment is that I convert each char to ASCII, but that takes about 3-times more space in the db. Quote Link to comment https://forums.phpfreaks.com/topic/167120-uploading-files-to-sqlite2/ Share on other sites More sharing options...
artacus Posted July 23, 2009 Share Posted July 23, 2009 I'm not an sqlite expert, but I've got to question the decision to store blobs in an embedded database. You'd be better off storing the file in the file system and storing the link to it in the db. That said, if you want to store a blob, you'll need to use the right tools http://www.sqlite.org/c3ref/blob.html Quote Link to comment https://forums.phpfreaks.com/topic/167120-uploading-files-to-sqlite2/#findComment-881245 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.