cybercookie72 Posted December 7, 2008 Share Posted December 7, 2008 greetings all I have a project that requires me to have an image in the db (i know...not the best thing to do from what I am told). I have found some sample code on the net that I have been working with but can not seem to get the insert to work in the table I am using. The sample code works fine with the sample table ... but when I change to try and get it to insert in my table it does not work. The sample table specs are in the code and here is my table:: CREATE TABLE art_tb ( picture longblob NOT NULL, title varchar(20) NOT NULL, disc varchar(200) DEFAULT NULL, date_created DATE, catagory varchar(20), user_id int(4), date_posted DATE ); I did get it to work earlier and was able to insert into the picture and title (there are two rows with info in those columns) but I changed something and am dead in the water again. thank you in advance for any and all help.. I am pretty new to php so please explain as much as possable. I am trying to get something like this to work so that I can pull information from a form:: //desc is key word so i used disc mysql_query ("insert into art_tb (picture, title, disc, date_created, catagory, user_id, date_posted) values (". $image .", ". $_REQUEST[whatsit] .", 'techno pic', now(), 'Technology', 1, now())"); here is the code I am working on now that is more like the original code just the two columns:: mysql_query ("insert into art_tb (title, picture) values (". $_REQUEST[whatsit]. ", ". $image. ")"); I am not sure what I did right to get the two inserts to work and I have no clue what I did to break it. Here is the test page code...it is all in one php file called index.php::: [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/135891-cant-figure-out-why-binary-insert-wont-work/ Share on other sites More sharing options...
Mchl Posted December 7, 2008 Share Posted December 7, 2008 Do yo get any error messages? Try mysql_error to echo sql errors if they happen. mysql_query("/*query here*/") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/135891-cant-figure-out-why-binary-insert-wont-work/#findComment-708435 Share on other sites More sharing options...
cybercookie72 Posted December 7, 2008 Author Share Posted December 7, 2008 yes? something ugly??? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\0JFIF\0\0\0\0\0\0ÿþ\0>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default ' at line 1 any clue as to what that error means? by the way thank you for the reply... Link to comment https://forums.phpfreaks.com/topic/135891-cant-figure-out-why-binary-insert-wont-work/#findComment-708445 Share on other sites More sharing options...
cybercookie72 Posted December 7, 2008 Author Share Posted December 7, 2008 OK I did an echo before the mysql_query and saw that the image gets sent like::: insert into art_tb (picture, title, disc, date_created, catagory, user_id, date_posted) values (ÿØÿà\0JFIF\0\0\0\0\0\0ÿþ\0>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛ\0C\0 with A LOT MORE of the funny text. There are TONS of slashes in there, would they be causing the error? Do I need to format the query with slashes something like this? mysql_query ("insert into art (picture, title, disc, date_created, catagory, user_id, date_posted) values (\"". $image."\", \"".$_REQUEST[whatsit]."\", 'techno pic', now(), 'Technology', 1, now())"); Link to comment https://forums.phpfreaks.com/topic/135891-cant-figure-out-why-binary-insert-wont-work/#findComment-708467 Share on other sites More sharing options...
Mchl Posted December 7, 2008 Share Posted December 7, 2008 Sorry, Not much time right now, but you might want to take a look at this http://www.onlamp.com/pub/a/php/2000/09/15/php_mysql.html?page=1 Link to comment https://forums.phpfreaks.com/topic/135891-cant-figure-out-why-binary-insert-wont-work/#findComment-708476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.