I can't seem to display the image..
Here is my code..

<?php
$user='root';
$server='localhost';
$db='db_gamecube';//database name
mysql_connect('localhost','root');
mysql_select_db($db);
$pass=$_POST['password'];
$uname=$_POST['uname'];

$sql="select * from tb_register where 
username ='$uname' and password='$pass'";
$result= mysql_query ($sql) or die (mysql_error());
if(mysql_num_rows($result)==1)
    {
        session_start();
        $_SESSION['guest']=$uname;
        echo "<form method ='post' action='login_edit.php'>";
        $records=mysql_fetch_assoc($result);
        echo "<table border =10>
<tr>
    <td><div align ='left'><body><h2>
        <font color='white'>Name : $records[FirstName] $records[LastName]</font></h2>
    </td>
</tr>
<input type=submit value=Submit name=submit></body></div>";

echo "<img src=image.php?username=".$records['username']." width=100% height=100%/>";
?>

<img src=image.php?username=".$records[username]." width=100 height=100/>";

the name of the image field on mysql is 'aphoto'

this is like a profile picture display.

please would you fix this code for me?..hoping to find results and advance thank you.

Recommended Answers

All 8 Replies

you havent closed the IF statement, you are missing "}"

Is the image stored in the DB?

Is the image displayed if you put the name in directly?

the image stored in the DB?

Is the image displayed if you put the name in directly?

well i closed the if statement
yes it is stored but if i put the name directly it shows random chars..

what is the column in your DB set to that holds the image?

I think this has to be Long BLOB or Big BLOB.

I would suggest however not hold images in the table, but holding only the file name. Loading an image out of the DB is very heavy on CPU and network

the column "aphoto"

mine is just plain blob.

yeah my friends also suggest that holding a picture to a database is a drag..

thay say i'll just create a folder where i can store the images then save the file path into mysql but i have no idea on doing this..

thanks for your suggestion.

'FirstName' 'LastName'  'Age'   'Gender'    'Username'  'Email'                'Password'    
  Sample       Person    18       Male        Sample    sample_sample@sample.com    a


         'aphoto'
  ÿØÿàJFIF^^ÿáWExifMM*...

this is what my databse looks like below the 'aphoto' is random letters.

<img src=image.php?username=".$records[username]." width=100 height=100/>";

i just dont know on what is th right syntax in this one..

the column "aphoto"

mine is just plain blob.

yeah my friends also suggest that holding a picture to a database is a drag..

thay say i'll just create a folder where i can store the images then save the file path into mysql but i have no idea on doing this..

thanks for your suggestion.

Have a look at this tut Click Here

thank you for the help! :))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.