elnexus
asked on
Retrieving a PDF file from a MSSQL data base with php
Here my code:
//connect data base and select the table....
....
//query
$SQuery = "select len,pdfdata from PDFTable where nid = 34"
// the entry exist
// fetch the only row
$row = mssql_fecth_row($SQuery);
// ok!!
header("Content-type: application/pdf");
header("Content-lenght: ".$row[0]);
print $row[1];
The script launch the PDF program, but it remains in the list of process getting the 100% of the CPU.
I think that the data are not completed, due to when i delete the headers lines, the binary code appears into the browser, but is not complete!!!, i think only it show 4096 bytes of the file instead of the 65470 of its real lenght.....
I did the same test using ASP .NET and the code, similar from the above works fine, but i need make it in PHP.
Any limitations?, any wrong in the php code? or maybe this language script is not ready to work with MSSQL Server?.
Thank´s in advantage.
//connect data base and select the table....
....
//query
$SQuery = "select len,pdfdata from PDFTable where nid = 34"
// the entry exist
// fetch the only row
$row = mssql_fecth_row($SQuery);
// ok!!
header("Content-type: application/pdf");
header("Content-lenght: ".$row[0]);
print $row[1];
The script launch the PDF program, but it remains in the list of process getting the 100% of the CPU.
I think that the data are not completed, due to when i delete the headers lines, the binary code appears into the browser, but is not complete!!!, i think only it show 4096 bytes of the file instead of the 65470 of its real lenght.....
I did the same test using ASP .NET and the code, similar from the above works fine, but i need make it in PHP.
Any limitations?, any wrong in the php code? or maybe this language script is not ready to work with MSSQL Server?.
Thank´s in advantage.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For your query it would look like:
$SQuery="SELECT len,pdfdata from PDFTable WHERE nid=34 DUMPFILE \"/tmp/temp.pdf\""
Then read in the file and display it.
By the way, if the PDF is 65470 bytes, I assume you are using MEDIUM BLOBs or larger?
-Peter