Hello CC,

On 26 Jan 2004 at 12:47, C C wrote:

> Hi,
> 
> I'm trying to insert binary data into a MS SQL Server database. Text
> files are added fine, but binary files with null bytes are not. The
> field I'm adding the binary data to is image type. I get an error about
> unclosed quotation marks at the null byte, but I've replaced ' with ''. 
> 
> I tried escaping the null byte with a backslach, but it just changes it
> to the string "\0" when I download it. 
> 
> Anyone have any ideas about this?

I don't have any experience with MS SQL, but imagine that escaping the input properly 
is crucial. Have you tried using mysql_escape_string? Contrary to what the name of the 
function suggests, it can be used to escape strings (even strings of binary data) for 
insertion in databases other than MySQL. The prototype of the function is:

STRING mysql_escape_string ( STRING unescaped_string )

My suggestion is that you try running your input through mysql_escape_string *only* 
and see if it does the trick. If you do that, please let me (us) know the results; I'm 
curious.

Cheers,

Erik

Reply via email to