Current location: Hot Scripts Forums » General Community » Script Requests » how to fetch image from mysql using php

how to fetch image from mysql using php

Reply
  #1 (permalink)  
Old 09-27-09, 04:52 PM
ryanfern86goa ryanfern86goa is offline
New Member
 
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
how to fetch image from mysql using php

hi there
I have created a table $query2="CREATE TABLE '$user1' ( id tinyint(3) unsigned not null auto_increment,
image blob not null, primary key(id))";
I have inserted quite a few pictures in it... when i try to display or fetch them i only get one picture dispalyed, thats the pic with id 1.heres my code
PHP Code:
<? session_start(); ?>
<?php
$user1
=$_SESSION["user1"];
$pass1=$_SESSION["pass1"];
@
mysql_connect("localhost""abc""abcd") or die("Can not connect to database: ".mysql_error());
@
mysql_select_db('test') or die("Can not select the database: ".mysql_error());
$query mysql_query('select image from $user1');
$row mysql_fetch_array($query);
$content $row['image'];
header('Content-type:image/jpg');
echo
$content;
?>
i want to display all the pictures in that database..
Any help would be appreciated.. thanks

Last edited by Nico; 09-27-09 at 04:55 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-27-09, 07:20 PM
wirehopper's Avatar
wirehopper wirehopper is offline
Community Liaison
 
Join Date: Feb 2006
Posts: 2,321
Thanks: 16
Thanked 90 Times in 88 Posts
You need to add some code to indicate which image, by id, to display, then you need a second PHP file to loop through the ids and display the images.

You might want to leave the images in the file system and store an id, name, and caption in the database. Databases can't search images for content, so they don't add much value as a storage mechanism.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-28-09, 06:18 AM
ryanfern86goa ryanfern86goa is offline
New Member
 
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
hi hopper
thanks for ur reply.. was thinking of doing it by using while loop but really dont know how to go around it as i am new to php n mysql.. can you plz let me know about this
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-28-09, 06:45 AM
wirehopper's Avatar
wirehopper wirehopper is offline
Community Liaison
 
Join Date: Feb 2006
Posts: 2,321
Thanks: 16
Thanked 90 Times in 88 Posts
There are excellent examples here.

PHP: mysql_query - Manual
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
div css theighost CSS 11 09-14-08 02:30 AM
WEB HOSTING - $4.99/MONTH For 1GB HD & 25GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 12-10-05 08:13 AM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 07-14-05 10:56 AM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 2 11-12-04 03:25 PM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 10-30-04 01:19 PM


All times are GMT -5. The time now is 03:57 AM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.