still trying to store binary data

wxdqz

New Member
I'm still trying to write a query for sql server that will take an image file and save it into a binary data field. here is my code:

function AccessAddSlashes($S)
{
$S=str_replace("\\'","''",$S);
$S=str_replace("\\\"","\"\"",$S);
return $S;
}


//open the database connection, the connection id will be used for subsquent queries
$connection_id = odbc_connect("DatabaseName", "uid", "pwd");

//formulate and execute SQL query
$image_data = AccessAddSlashes(fread(fopen("pic.jpg", "r", 1), filesize("pic.jpg")));
$update_query = "UPDATE Table
SET Graphic = '" . $image_data . "'" .
" WHERE Manufact_Name = 'Honda Motor Co.';";

$result_id = odbc_exec($connection_id, $update_query);

First, when and where do I need to put addslashes? (I need the special version of addslashes for sql server, so just accept that as a given.) Aside from that, does anyone see anything wrong with this..no matter how I tweak it, it doesn't work. If anyone can give me some insight, I'd be very happy.

Thanks again,

Sonny
 
Back
Top