Question about storing binary data in a mysql database.

notfred

Lifer
Feb 12, 2001
38,241
4
0
I need to store jpeg images in a mysql database. I'm using a certain scripting language, and have the jpeg file as a string. Do I need to escape anything in my string before storing it, or can I just do: inset into table values("$myjpegvariable");

I hope that makes sense.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
I have the table set up to use longblobs, I want to know how to write the insert statement.
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
Sorry, me brain dead today. Yes, you need to escape special characters before inserting into the database. What script are you using? With PHP you just need to use the addslashes() function to do it quickly.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: kt
Sorry, me brain dead today. Yes, you need to escape special characters before inserting into the database. What script are you using? With PHP you just need to use the addslashes() function to do it quickly.

I'm using perl with DBI. The documentation says to use quote(), but I tried that and it doesn't seem to give me valid data.

I'll read it again tomorrow.
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
Originally posted by: notfred
Originally posted by: kt
Sorry, me brain dead today. Yes, you need to escape special characters before inserting into the database. What script are you using? With PHP you just need to use the addslashes() function to do it quickly.

I'm using perl with DBI. The documentation says to use quote(), but I tried that and it doesn't seem to give me valid data.

I'll read it again tomorrow.

Hmm.. strange. I've used the quote() function in DBI and haven't run into this problem before. Did you run the quote() function on your data string or your SQL statement string?