Page 1 of 1

Adding and deleting images to a database

Posted: Tue Apr 15, 2008 1:06 pm
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; 
 
?>

Re: ADDING AND DELETTING IMAGES PLEASE HELP

Posted: Tue Apr 15, 2008 1:29 pm
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!

Re: ADDING AND DELETTING IMAGES PLEASE HELP

Posted: Tue Apr 15, 2008 2:06 pm
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!)

Re: ADDING AND DELETTING IMAGES PLEASE HELP

Posted: Wed Apr 16, 2008 9:09 am
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.

Re: Adding and deleting images

Posted: Wed Apr 16, 2008 9:10 am
by John Cartwright
Thanks for ignoring me. :banghead: