tags:

views:

18

answers:

1

Hello,

Can someone explain to me why this happens?

I have a file called profile.php, where I want to echo out a user's photo by reading its file path from MySQL. The code is below:

echo "<img src=\"{$row['PortraitPath']}\" />";

Some of the code that represents how a file path for the photo is saved is presented below (uploader.php):

$sess_userid = mysql_real_escape_string($_SESSION['userid']);
$Image = mysql_real_escape_string($prod_img_thumb);
$PortraitPath = mysql_real_escape_string($prod_img_thumb);

$query  = "UPDATE Members 
            SET PortraitPath = '$PortraitPath',
                Image = '$Image'
            WHERE fldID='$sess_userid'"; 

$result = mysql_query($query) or trigger_error(mysql_error().$query);

mysql_close($con);

Now, I am ABLE to properly save the file path to my database, but what I noticed was that as soon as I click the 'back button' on my browser, the file path will be deleted from MySQL, and hence, I won't be able to display the picture no longer on profile.php. Whereas, if I decide to manually type in profile.php for the website, the file path won't be deleted. Can someone explain to me why this happens and how I may be able to get around it?

Thank you.

+1  A: 

I am going to guess that it is because you call the uploader.php again on the same page and the

 '$PortraitPath' 

is set to 0 so it updates it again.

btrandom