pulling a BLOB from SQL2k works with Java but corrupts with PHP

Hi
I'm pulling back some data with Java and all works fine yet I want to move from Java to PHP and have mimicked the requirements with all working well except the PDF files that are created simply give the message "There was an error opening this document. The file is damaged and could not be repaired"

Any idea's what I'm doing wrong? as I say if I use the same code (but ported to Java) it works fine?

I've attachec the code below and a copy of the created pdf (just amended extension to .txt)

Thanks
Neil
<?php 
header("Content-Type: application/pdf"); 	
 
$docPath = "" . $_GET['from'];	
$server="####";
$username="####";
$password="####";
$db = "####";
$sqlconnect=mssql_connect($server, $username, $password);
$sqldb=mssql_select_db($db,$sqlconnect);	
 
$sql="SELECT c_content"
. "\n FROM ####.####.t_cadsdoc"
. "\n WHERE c_reference = '" . mysql_escape_string( $docPath ) . "'"
;
$results = mssql_query($sql);
$row=mssql_fetch_array($results);	
mssql_close($sqlconnect);
		
echo $row['c_content'];	
?>

Open in new window

buildPDF.txt
LVL 3
Neil ThompsonSenior Systems DeveloperAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hernst42Connect With a Mentor Commented:
AFAIk you can't read blobs via the mssql_fetch_array-funvtion.
Check out http://odbtp.sourceforge.net/ as a possible solution for this issue, or try stored procured with mssql like described
http://www.php.net/manual/en/function.mssql-bind.php
0
 
Neil ThompsonSenior Systems DeveloperAuthor Commented:
I've jus tfound out the PHP created file when opening in textpad is about 50 times smaller than the correct PDF file opened in textpad
0
 
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Apologies for delay in grading, just back from hols
Neil
0
All Courses

From novice to tech pro — start learning today.