Page 1 of 1

Show images/pictures from SQL database

Posted: Sat Jul 17, 2004 10:57 pm
by Memphis
Hi!
I have a query that gets and outputs pictures from an SQL database.
Here is the code

Code: Select all

<?PHP
  $fname = $_POST["fname"];
  $lname = $_POST["lname"];
  
  $connectionstring = odbc_connect("photos","","");

  $query = "SELECT firstname, lastname, image FROM ImageDB WHERE(firstname=$fname AND lastname=$lname)";

  $queryexec = odbc_exec($connectiontsring, $query);
  $result = odbc_fetch_array($queryexec);

  echo $result['firstname'] . "<BR>" . $result['lastname'] . "<BR>";

  $filename = "photo.jpg";
  $fp = fopen ($filename, "w");
  echo "<img src="$filename"><BR>";
  fclose($fp);
  unlink ($filename);
?>
"Image" is binary datatype.
My problem is this: Since the size of all variables in PHP is 4kb, I can only see that much of the photo. The rest just does not show up.
Is there any way that I can get around this problem?

Thanks.

Posted: Sat Jul 17, 2004 11:29 pm
by feyd
I haven't ever had a problem with very large variables.. I routinely have 130K binary image strings floating in my scripts..

your script opens and truncates $filename, closes it, then deletes it.. all without letting the browser actually read the file..