download from mysql script
| From: | Anthony Ritter | Date: | Mon, 24 Nov 2003 01:41:36 +0000 |
| Subject: | download from mysql script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-170750@lists.php.net to get a copy of this message | ||
I'm trying to receive data from a mysql database through php.
Using the command line at mysql listed below gives me a result set.
I am able to connect to the database through php, however, when using the
following script, I receive no data when the data is in the table called
pictures in the db called sitename.
<?
if($ID) {
@MYSQL_CONNECT("localhost","root","thepassword");
@mysql_select_db("sitename");
$query = "select bin_data,filetype from pictures where ID=$ID";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
$type = @MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
echo $data;
}
?>
// In browser window it reads:
// http://localhost/download.php?filename=7
//...and on the Command Line using the following query:
// SELECT filetype FROM pictures where ID=$ID
// gives me a image/pjpeg as the result set.