i have store an image on the server from a file upload with a random number attached to it. i have then stored the random number in a mysql db for use on other pages to display the images.
the problem i am having is that the image will not display on other pages when i try to recall it from the server.
i have stored the image in a folder on the server using this code
"image/thumbs/thumb_".$image_name . $rand;
$image_name being the name of the file to be stored and $rand being the random number. i have then stored the random number in the db using
$rand= rand(0, 100);
$sql="INSERT INTO random_number (random1) VALUES ('$rand')";
$query = mysql_query($sql);
to get the file from the server to be displayed the code i have used is this
$image = "";
$broad_img1= "";
$path= 'http://www.acmeart.co.uk/mercury/';
$web_image_folder = 'image/thumbs';
$exts = array('jpg', 'png', 'gif', 'jpeg');
$image_name = 'thumb_image1';
// check for each extension
foreach($exts as $ext) {
if (file_exists($web_image_folder.'/'.$image_name.'.'.$ext . $rand)) {
$image = $image_name.'.'.$ext . $rand;
}
}
// check if we have an image
if ($image != "") {
// ok we have the image
$broad_img1='<img src="' . $path."/".$web_image_folder."/".$image . '" />';
} else {
// error, we can't find the image.
}
this code worked fine before i was adding the random number. it retrieved the image and displayed the cached version (when cached cleared displayed new upload image).
i have got the random number out of the db using this code
$query = "SELECT random1 FROM random_number";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$rand="{$row['random1']}";
the number is then placed into the variable and then tried to be used to display the image but the image will not display. it may be the way i have written the code to retrieve the image but my eyes are tired of looking so i dont think i would see a mistake if it slapped me.
i will post the second half of the code in full below.