|
Author |
Message |
badger
Junior WebHelper
Joined: 08 Oct 2004
Posts: 10
|
Posted:
Thu Dec 30, 2004 4:58 pm (19 years, 12 months ago) |
|
Hi peeps,
Im having an issue getting viewing images I have added to a mysql database. I have a dump of the database below.
Code: | CREATE TABLE binary_data_files (
file_id tinyint(3) unsigned NOT NULL auto_increment,
bin_data mediumblob NOT NULL,
description tinytext NOT NULL,
filename varchar(50) NOT NULL,
filesize varchar(50) NOT NULL,
filetype varchar(50) NOT NULL,
PRIMARY KEY (file_id)
); |
I can successfully add blob images to the database but when trying to call them for usage just simply doesn't work.
The script I am trying to use is below.
Code: | <?php
global $id;
if(!is_numeric($id))
die("Invalid file_id specified");
$dbServer = "localhost";
$dbDatabase = "phone";
$dbUser = "root";
$dbPass = "";
$sConn = mysql_connect($dbServer, $dbUser, $dbPass)
or die("Couldn't connect to database server");
$dConn = mysql_select_db($dbDatabase, $sConn)
or die("Couldn't connect to database $dbDatabase");
$dbQuery = "SELECT bin_data, filetype";
$dbQuery .= "FROM binary_data_files";
$dbQuery .= "WHERE file_id = $id";
$result = mysql_query($dbQuery) or die("Couldn't get file list");
if(mysql_num_rows($result) == 1)
{
$filetype = @mysql_result($result, 0, "filetype");
$filecontent = @mysql_result($result, 0, "bin_data");
header("Content-type: $filetype");
echo $filecontent;
}
else
{
echo "Record doesn't exist.";
}
?> |
Everytime I try to call an image (view.php?id=1) I get "Couldn't get file list"?
Can anyone help?
Thanks
Badger! |
|
|
|
|
adam
Forum Moderator & Developer
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Sat Jan 01, 2005 4:35 pm (19 years, 11 months ago) |
|
Add the following after the query and before the script is killed (with die() ):
Code: | print mysql_error(); |
That should let you know what's going wrong. |
________________________________ It's turtles all the way down... |
|
|
|
badger
Junior WebHelper
Joined: 08 Oct 2004
Posts: 10
|
Posted:
Sun Jan 09, 2005 8:51 pm (19 years, 11 months ago) |
|
|
|
|
zeeshan002
Junior WebHelper
Joined: 21 Apr 2015
Posts: 1
|
Posted:
Tue Apr 21, 2015 6:27 am (9 years, 8 months ago) |
|
Everytime I try to call an image (view.php?id=1) I get "Couldn't get file list"?
__________________
aliiii |
________________________________ aliiii |
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.127724 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |