Link to home
Start Free TrialLog in
Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
Avatar of Neil Thompson
Neil Thompson
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Apologies for delay in grading, just back from hols
Neil