954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

retrieving image from mysql database using php


<?php
$a = mysql_connect("localhost","root","");
if (!$a){
die ("
ERROR in mysql_connect
");
} else
$db = mysql_select_db('test');
$query = "SELECT * FROM image";
echo "
line 16.....
";
$result = mysql_query($query) or die('Error, line 17 query failed');

if(mysql_num_rows($result) == 0)
{
echo "Database is empty
";
}
else
{
while(list($id, $name) = mysql_fetch_array($result))
{
echo "
line 25.....
";
echo "
";
echo "line 31......";
}
}
mysql_close();
?>

alfredtiu
Newbie Poster
1 post since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

You should not send any output to the browser before

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");

Always header() should be the first to send output to the browser.

Try removing all the echo statements in that file above header()

PeppySoft
Newbie Poster
6 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

hi buddies,
please explain me how to retrive the image from database,i am beginner in php.below i present my coding.if any error please explain about that.
by,
ur friend
kalpana

<?php
session_start();
$db=mysql_connect('localhost','root','');
mysql_select_db('registration',$db);

$se=mysql_query("select * from reg1 where username='".$_SESSION['username']."'");

while($r=mysql_fetch_array($se))
{

?>

EMAIL USERNAME DISPLAYNAME FIRSTNAME MIDDLENAME LASTNAME PHONE PASSWORD RETYPEPASSWORD LANGUAGE COUNTRY STATES ZIPCODE IMAGE

<?

}
?>

kalpanasarvan
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You