Adding and deleting images to a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
topboi
Forum Newbie
Posts: 2
Joined: Tue Apr 15, 2008 1:00 pm

Adding and deleting images to a database

Post by topboi »

right ive created a imagetest table in phpmyadmin and added a image to it, i can view the first image however when i add another image i am having trouble viewing the 2nd image ie 'nokia' can anyone help? my code is as follows only OutBack image is displayed:

Code: Select all

<?php
$DB_Host = "xxxxxx";
$DB_Username = "xxxxxx";
$DB_Password = "xxxxx";
$DB_Name = "xxxxxxx";
 
$ret=mysql_connect($DB_Host, $DB_Username, $DB_Password) or die ("Can no connect");
$db=mysql_select_db($DB_Name);
 
 
$sql=" SELECT image FROM `imagetest` WHERE Name = 'OutBack' LIMIT 0 , 30 ";
$result=mysql_query($sql);
$row=mysql_fetch_row($result);
$img=$row[0];
header("Content-Type: image/jpeg");
print "$img";&#160; 
 
$db=mysql_select_db($DB_Name);
$sql=" SELECT image FROM `imagetest` WHERE Name = 'nokia' LIMIT 0 , 30 ";
$result=mysql_query($sql);
$row=mysql_fetch_row($result);
$img=$row[0];
header("Content-Type: image/jpeg");
print "$img";&#160; 
 
?>
Last edited by topboi on Wed Apr 16, 2008 9:16 am, edited 3 times in total.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: ADDING AND DELETTING IMAGES PLEASE HELP

Post by andym01480 »

You can't send headers twice. If you really want to store images in a database and then output more than once you will need to start playing with php's image functions.

Far easier (and more efficient) would be to store images as images on the server and store the filenames in a database!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: ADDING AND DELETTING IMAGES PLEASE HELP

Post by John Cartwright »

Please change your title to correct capitalization, and...
Forum Rules wrote:
  • 2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Infact, I would seriously recommend you read the forum rules (found in my signature), since you've already violated a couple of our rules on your first post. (thats ok as long as it doesn't happen again!)
topboi
Forum Newbie
Posts: 2
Joined: Tue Apr 15, 2008 1:00 pm

Re: ADDING AND DELETTING IMAGES PLEASE HELP

Post by topboi »

sorry about that i didnt know...

i have to store the images on the database because that is the way i an trying to get it to work any more suggestions on how i can get it to display further images.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Adding and deleting images

Post by John Cartwright »

Thanks for ignoring me. :banghead:
Post Reply