Hi,
I have a problem with loading images where the image path is called from a MySQL database.
Basically the project is to show photographs from a database, but each user has a certain ID and password and has access to certain photos.
The way the scripts work is the user logs on to a webpage, the ID and password are checked against a Password table within a MySQL database - within the same row as the ID and password is a gallery number.
This same gallery number is used within the Gallery table, and this table has the image name, e.g. a001.jpg and also a gallery number (which matches to the Password table)
The way in which the webpages work is the user enters their ID and password to the log in screen and this could send the following URL to the next page for user 1:
http://www.mysite.com/myphotos.php?username=john&password=doe&gallery=1
or maybe the following for user 2:
http://www.mysite.com/myphotos.php?username=jane&password=doe&gallery=2
The myphotos.php has the following mysql_query:
$result = mysql_query("select * from gallery WHERE gallery='$gallery' ORDER BY number LIMIT 0, 50");
and further down the page echos this out with the following:
<?php
$columns=6;
$n=-1;
echo "<tr>\n";
while($row = mysql_fetch_array($result))
{
$n++;
if ($n == $columns)
{$n=0;echo"</tr>\n";echo"<tr>\n";}
?>
<?php
foreach($_POST as $key=>$value){
if ($key!="submit"){
$value=htmlentities(stripslashes(strip_tags($value)));
echo "\t<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
}
}
?>
<td width="8%" valign="top"><div align="center">
<p align="center"><a href="javascript:popUp('photographorder1.php?photo=<? echo $row["image"]; ?>')"><img src="<?php echo $row["image"]; ?>" border="0" align="center"></a><br>
<br>
<br>
</p>
</div></td>
<?php }
echo "</tr>\
?>
Now the gallery table could show the following entries (shown as two columns the first 'image' - the second 'gallery'):
a001.jpg - 1
a002.jpg - 1
b001.jpg - 2
b002.jpg - 2
So if Jane Doe entered her username and password then photos b001.jpg and b002.jpg should be shown, and if John Doe entered his username and password then a001.jpg and a002.jpg should be shown.
Theoretically this runs fine, except for one small (but major) problem. If Jane Doe enters her username and password the source code of the page correctly shows it is displaying images
b001.jpg and b002.jpg (even if you right click, and select properties on the image it shows as either b001.jpg or b002.jpg) but actually displays photos a001.jpg and a002.jpg!
In actual fact photos b001.jpg and b002.jpg have not been uploaded to the webspace as of yet so it really should be indicating it can not find the photo - does anyone know why it would revert back and show images a001.jpg and a002.jpg (which have been uploaded to the webspace) ?
This problem has been giving me a big headache!
Many thanks,
Dean