Page 1 of 1

getting error with >CREATOR: gd-jpeg v1.0 on insert?

Posted: Sun Dec 07, 2008 5:54 am
by cybercookie72
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:::



I get an error from the mysql_query() that I no clue about. Thank you all in advance for any help:::

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



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?



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())");