0

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.

2
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by HometownHero
0

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?

0

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..

0

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

0

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.

0
'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.

Edited by HometownHero: much more clearer

0

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

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.