473,387 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem viewing image blobs

38
Hi there, I did post yesterday regarding an error I had with this script - which was solved. Unfortunately now the script doesn't actually result in anything! Not even an error.

The script below is supposed to pull the image blob data out of the database depending on the id sent via a html image tag. I know that part works correctly so the problem must be with the script. I'm just not sure where.

First the html code...

[HTML]
<img src='php/image.php?albumNumber=$albumNumber'/>
[/HTML]

Now the php...

[PHP]
<?php
if(isset($_GET['albumNumber']))
{
mysql_connect("","","");
mysql_select_db("");

$albumNumber = $_GET['albumNumber'];
$query = "SELECT content FROM Albums WHERE albumNumber = '$albumNumber'";

$result = mysql_query($query);
$content=$r['content'];

header("Content-Type: image/jpeg");
echo $content;
}
?>
[/PHP]


I'm really stuck on this one - especially with no error!
'content' is the column storing all the image data in the database.

Thanks.
Oct 15 '07 #1
3 1349
pbmods
5,821 Expert 4TB
Heya, Philth.

Where do you call mysql_fetch_assoc() to pull the data from the MySQL result resource?
Oct 16 '07 #2
Philth
38
Thanks for that. I've added this line, so the script reads as follows...

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. if(isset($_GET['albumNumber'])) 
  4. {
  5. mysql_connect("","",""); 
  6. mysql_select_db("freelance"); 
  7.  
  8. $albumNumber = $_GET['albumNumber'];
  9. $query = "SELECT content FROM Albums WHERE albumNumber = '$albumNumber'";
  10.  
  11. $result = mysql_query($query);
  12. $content = mysql_fetch_row($result);
  13.  
  14.  
  15. header("Content-Type: image/jpeg"); 
  16. echo $content;
  17. ?>
  18.  
  19.  

Still does nothing. When the image I'm trying to display is uploaded to the database I'm storing the file name, the file size, the file type and all the garbled data(content). I am correct in trying to retrieve the data in the content field?
Oct 16 '07 #3
Lumpy
69
Your close, but give this a try...
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. if(isset($_GET['albumNumber'])) 
  4. {
  5. mysql_connect("","",""); 
  6. mysql_select_db("freelance"); 
  7.  
  8. $albumNumber = $_GET['albumNumber'];
  9. $query = "SELECT content FROM Albums WHERE albumNumber = '$albumNumber'";
  10.  
  11. $result = mysql_query($query);
  12. $row = mysql_fetch_assoc($result);
  13. $content = $row['content'];
  14.  
  15. header("Content-Type: image/jpeg"); 
  16. echo $content;
  17. ?>
  18.  
  19.  
Oct 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bj?rn Terje Svennes | last post by:
I'm using ODBC to interface a Microsoft SQL Server 2000. One of the operations involves placing files within BLOBs. I'm using the image data type for this purpose. Most of the time this works okey,...
1
by: John Thompson | last post by:
We're sooo close. When we load the page to upload the image, all of the prms go through except the binary image data. Using SQL server with the data type set to "image". Please help! Thanks-...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
3
by: meyvn77 | last post by:
Hello - I am looking for the best way to store images in a Access DB. My Idea - I have a table with 150,000 records. These recoreds represent a Crash (Traffic Accident). I have 50 different...
8
by: yoyo | last post by:
Ok, I think I just may be a moron, but where the heck are the Image extenders found? I've look all around, tried all the DB2 cd's I have, are they installed by default somewhere? Which install...
10
by: NH | last post by:
I have a girdview with paging enabled. How can I add a message in the footer to say "Viewing records 1-15 of 45" etc Thanks
2
by: Mikael | last post by:
I have a database made up of students' profiles. I would like the form to have an object that displays the student's picture. I used to use gifs and ole object fields, but I recently switched to...
12
by: NOO Recursion | last post by:
Hi everyone! I am trying to write a program that will search a 12x12 for a thing called a "blob". A blob in the grid is made up of asterisks. A blob contains at least one asterisk. If an...
7
by: raknin | last post by:
Hi I have a carousel script. I want to load the carousel with a new set of pictures every time I press a button. The problem that I have that the script append the new pictures to the olds one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.