Re: php, sql server and image fields

From: Date: Wed, 30 Apr 2003 14:21:08 +0000
Subject: Re: php, sql server and image fields
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145778@lists.php.net to get a copy of this message
use addslashes($file_contents) before inserting it into the database csr wrote:
could anyone help me. I am trying to upload a jpg file into a ms sql server 2000 database with an image field and it's not working. This is the code so far.. $file = fopen ($HTTP_POST_FILES['upload_file']['tmp_name'],'rb')
           or die ("File Open Failed ");  //this is the jpg file
$file_contents = fread ($file, filesize ($HTTP_POST_FILES['upload_file']['tmp_name'])) or die (" Can't read "); fclose ($file); //put file in database mssql_connect(HOST,USER,PASS) or die("unable to connect"); mssql_select_db(PICTURE_DBASE) or die("unable to select database"); //file data is the image field in the table files mssql_query($SQL="Insert into files (file_data) values ('$file_contents')")
                   or die("MSSQL Query error: ". "<br><br>" );
I got all sort of error messages from ms sql any ideas. thanks a lot csr.


« previous php.general (#145778) next »