Jump to content

unable to display image on web page


smitagodbole

Recommended Posts

Hi,

I am a newbie to this forum and php as well.  I have a script which inserts data and image file into mysql database.  Now I want to display this image on web  page but unable to do it.  I tried a lot but couldn't find out any solution.  I would appreciate your help.

<?php

 

$con = mysql_connect("localhost", "root", "xx");

if(!$con)

{

die('Could not connect:' .mysql_error());

}

mysql_select_db("yyy",$con);

 

$memberid = '$_POST[memberid]';

$fname = '$_POST[fname]';

$lname = '$_POST[lname]';

$gender= '$_POST[gender]';

$add1 = '$_POST[add1]';

$add2 = '$_POST[add2]';

$city = '$_POST[city]';

$state = '$_POST[state]';

$zip = '$_POST[zip]';

$country = '$_POST[country]';

 

$photo1 = '$_FILES[image][name]';

echo "$photo1";

 

//if ($memberid= $_GET['memberid']){

$query="select memberid,fname,lname,gender,add1,add2,city,state,zip,country,photo1 from vadhuvar_member where memberid =(select max(memberid)from vadhuvar_member)";

 

$result=mysql_query($query) or die(mysql_error());

 

 

while($row = mysql_fetch_assoc($result))

{

$memberid = $row['memberid'];

$fname = $row['fname'];

$lname = $row['lname'];

$gender = $row['gender'];

$add1 = $row['add1'];

$add2 = $row['add2'];

$city = $row['city'];

$state = $row['state'];

$zip = $row['zip'];

$country = $row['country'];

//$photo1=chunk_split(base64_encode($photo1));

$photo1 = $row['photo1'];

 

//echo base64_encode($photo1);

 

 

echo "Name:$fname $lname<br>";

//echo "Name:$_POST[fname]$_POST[lname]<br>";

echo "Gender:$gender<br>";

echo "Address:$add1 $add2<br>";

echo "$city $state $zip<br>";

echo "$country<br>";

//echo "<img src=".upload/$photo1 ." alt="" width="200" height="300" /><br />";

 

 

    }

//}

?>

 

 

<!--img src="<?php echo '.upload/$_FILES[image][name]?memberid=$row[memberid]'?>"alt="" width="200" height="300"/-->;

<?php echo "<img src=". upload/$row[photo1]" alt="" width="200" height="300">";?>

<!--img src="<?php echo ".\upload\$photo1" ?>" alt=""  width="200" height="300"/-->;

 

<? set_magic_quotes_runtime(1); // turn back on ?>

Thanks

Smita

Link to comment
https://forums.phpfreaks.com/topic/211910-unable-to-display-image-on-web-page/
Share on other sites

Hi,

I am a newbie to this forum and php as well.  I have a script which inserts data and image file into mysql database.  Now I want to display this image on web  page but unable to do it.  I tried a lot but couldn't find out any solution.  I would appreciate your help.

<?php

 

$con = mysql_connect("localhost", "root", "xx");

if(!$con)

{

die('Could not connect:' .mysql_error());

}

mysql_select_db("yyy",$con);

 

$memberid = '$_POST[memberid]';

$fname = '$_POST[fname]';

$lname = '$_POST[lname]';

$gender= '$_POST[gender]';

$add1 = '$_POST[add1]';

$add2 = '$_POST[add2]';

$city = '$_POST[city]';

$state = '$_POST[state]';

$zip = '$_POST[zip]';

$country = '$_POST[country]';

 

$photo1 = '$_FILES[image][name]';

echo "$photo1";

 

//if ($memberid= $_GET['memberid']){

$query="select memberid,fname,lname,gender,add1,add2,city,state,zip,country,photo1 from vadhuvar_member where memberid =(select max(memberid)from vadhuvar_member)";

 

$result=mysql_query($query) or die(mysql_error());

 

 

while($row = mysql_fetch_assoc($result))

{

$memberid = $row['memberid'];

$fname = $row['fname'];

$lname = $row['lname'];

$gender = $row['gender'];

$add1 = $row['add1'];

$add2 = $row['add2'];

$city = $row['city'];

$state = $row['state'];

$zip = $row['zip'];

$country = $row['country'];

//$photo1=chunk_split(base64_encode($photo1));

$photo1 = $row['photo1'];

 

//echo base64_encode($photo1);

 

 

echo "Name:$fname $lname<br>";

//echo "Name:$_POST[fname]$_POST[lname]<br>";

echo "Gender:$gender<br>";

echo "Address:$add1 $add2<br>";

echo "$city $state $zip<br>";

echo "$country<br>";

//echo "<img src=".upload/$photo1 ." alt="" width="200" height="300" /><br />";

 

 

    }

//}

?>

 

 

<!--img src="<?php echo '.upload/$_FILES[image][name]?memberid=$row[memberid]'?>"alt="" width="200" height="300"/-->;

<?php echo "<img src=". upload/$row[photo1]" alt="" width="200" height="300">";?>

<!--img src="<?php echo ".\upload\$photo1" ?>" alt=""  width="200" height="300"/-->;

 

<? set_magic_quotes_runtime(1); // turn back on ?>

Thanks

Smita

 

You know... if you run that script, it should be spitting a bunch of errors at you. Try turning error_reporting on and that should be the key.

error reporting is already on.  It is showing me such as.....

;  Default Value: E_ALL & ~E_NOTICE

;  Development Value: E_ALL & ~E_NOTICE?(I hope this is correct)

Actually, I am seeing all other info such as name,gender and address etc except image.  I am seeing  empty frame for photo.

Thanks

Smita 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.