mike12255 Posted February 1, 2009 Share Posted February 1, 2009 I have made some code that chooses a random image and displays it, i have spots for three images and all them apear with that white box that has the X in the top left that means picture not found. I cannot seem to figure out the problem, here is my code: <?php // Change this to the total number of images in the folder $total = "11"; // Change to the type of files to use eg. .jpg or .gif $file_type = ".gif"; // Change to the location of the folder containing the images $image_folder = "images/random"; // You do not need to edit below this line $start = "1"; $random = mt_rand($start, $total); $temp1; if ($temp1 < 1){ $temp1 = $random; } if ($temp1 > 0){ $temp2 = $random; } if ($temp1 > 0 && $temp2 > 0){ $temp3 = $random; } $image_name = $random . $file_type; } randomint($image_name); if(randomint($temp1) == randomint($temp2) || randomint($temp1) == randomint($temp3) || randomint($temp3) == randomint($temp2)){ randomint($image_name); }else{ $img1 = randomint($image_name); } randomint($image_name); if(randomint($temp1) == randomint($temp2) || randomint($temp1) == randomint($temp3) || randomint($temp3) == randomint($temp2)){ randomint($image_name); }else{ $img2 = randomint($image_name); } randomint($image_name); if(randomint($temp1) == randomint($temp2) || randomint($temp1) == randomint($temp3) || randomint($temp3) == randomint($temp2)){ randomint($image_name); }else{ $img3 = randomint($image_name); } ?> Quote Link to comment Share on other sites More sharing options...
Lucky_PHP_MAN Posted February 1, 2009 Share Posted February 1, 2009 I would assume that all these images are inside "Images/Random/" folder. If so, you might need to add a slash at the end of your $image_folder string. // Change to the location of the folder containing the images $image_folder = "images/random/"; // added a slash at the end The above will point the image to "images/random/{random_number}.gif Hope it helps Regards, LPM Quote Link to comment Share on other sites More sharing options...
mike12255 Posted February 1, 2009 Author Share Posted February 1, 2009 actually to be honset i dont even use that line, i ment to take that out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.