Hi there!
Background
As part of an application I'm writing I need to upload GIFs / JPEGs / PDFs to a MSSQL v7 database.
I've prototyped the application using RH7, PHP4-4.0.4pl1 and MySQL-3.23.38 and it works like a dream.
I then moved it across to NT4 / Apache / MSSQL (I'm using PHPLIB so this should have been relatively easy!) and other than some issues with field types etc. the application works.
The application has an administration module that lets the user add content to certain areas, hence the uploading of images.
The problem
The problem I have is that when I try to insert the image into the db I get an error saying 'Unclosed quotation mark before the character string...'.
I've tracked this down to the fact that the binary image file contains nulls (no surprises there!) but the string seems to get truncated at that point.
If I strip out all the chr(0)'s the insert works ok. Obviously the image wont display the at least it gets into the db!
I've spent a few days now searching for a solution but nothing seems to match on the web, hence this post.
I've tried using PHP's native MSSQL commands (rather than via PHPLIB), same problem.
I've tried using ODBC, same problem.
I suppose I could replace the chr(0) with something else then convert them back when I need to display the image, but there must be a better way?
In addition, I've tried escaping 'special' characters via magic-quotes-gpc in php.ini and switched the sybase option on as well. I've also tried doing this manually via str_replace, all to no avail.
Any help greatly appreciated.
Many thanks, Steve
Background
As part of an application I'm writing I need to upload GIFs / JPEGs / PDFs to a MSSQL v7 database.
I've prototyped the application using RH7, PHP4-4.0.4pl1 and MySQL-3.23.38 and it works like a dream.
I then moved it across to NT4 / Apache / MSSQL (I'm using PHPLIB so this should have been relatively easy!) and other than some issues with field types etc. the application works.
The application has an administration module that lets the user add content to certain areas, hence the uploading of images.
The problem
The problem I have is that when I try to insert the image into the db I get an error saying 'Unclosed quotation mark before the character string...'.
I've tracked this down to the fact that the binary image file contains nulls (no surprises there!) but the string seems to get truncated at that point.
If I strip out all the chr(0)'s the insert works ok. Obviously the image wont display the at least it gets into the db!
I've spent a few days now searching for a solution but nothing seems to match on the web, hence this post.
I've tried using PHP's native MSSQL commands (rather than via PHPLIB), same problem.
I've tried using ODBC, same problem.
I suppose I could replace the chr(0) with something else then convert them back when I need to display the image, but there must be a better way?
In addition, I've tried escaping 'special' characters via magic-quotes-gpc in php.ini and switched the sybase option on as well. I've also tried doing this manually via str_replace, all to no avail.
Any help greatly appreciated.
Many thanks, Steve