Pange
02-09-2003, 03:51 PM
Hey! I'm fairly new to writing PHP, but I've handled a few small scripts on my website. I wrote this script, but it doesn't seem to work the way I want it to.
<?php
$game = basename($game);
{ $game="$game"; }
$image = basename($image);
{ $image="$image"; }
if(file_exists("$image.jpg")) {
$image = "$image.jpg";
echo "<img src=\"$game/$image\">"; }
else {
$image = "$image.gif";
echo "<img src=\"$game/$image\">"; }
?>
so basically, this script looks to see if the image.jpg exists. if it does, it shows the image on the page. if it doesn't, it will look for the same file name, but with a gif extension. I'm using dynamic links, so game = the directory where the image is stored, and image = the file in the directory to be loaded.
http://www.magitek.nu/ode2ff/layoutv2/gallery/gallery.php?image=main&game=ff9 tries to load this image: http://www.magitek.nu/ode2ff/layoutv2/gallery/ff9/main.jpg
http://www.magitek.nu/ode2ff/layoutv2/gallery/gallery.php?image=box&game=ff9 tries to load this image: http://www.magitek.nu/ode2ff/layoutv2/gallery/ff9/box.gif
for some reason, it is able to work for gif files, but any jpgs do not work. It's not a problem with that one jpg file, because I tried it here (http://www.magitek.nu/ode2ff/index2_1.php?ode=ff1_merch) as well and it does not work...
if anyone has any information on this to help, I will be very greatful. This is driving me insane, lol. thanks! =)
<?php
$game = basename($game);
{ $game="$game"; }
$image = basename($image);
{ $image="$image"; }
if(file_exists("$image.jpg")) {
$image = "$image.jpg";
echo "<img src=\"$game/$image\">"; }
else {
$image = "$image.gif";
echo "<img src=\"$game/$image\">"; }
?>
so basically, this script looks to see if the image.jpg exists. if it does, it shows the image on the page. if it doesn't, it will look for the same file name, but with a gif extension. I'm using dynamic links, so game = the directory where the image is stored, and image = the file in the directory to be loaded.
http://www.magitek.nu/ode2ff/layoutv2/gallery/gallery.php?image=main&game=ff9 tries to load this image: http://www.magitek.nu/ode2ff/layoutv2/gallery/ff9/main.jpg
http://www.magitek.nu/ode2ff/layoutv2/gallery/gallery.php?image=box&game=ff9 tries to load this image: http://www.magitek.nu/ode2ff/layoutv2/gallery/ff9/box.gif
for some reason, it is able to work for gif files, but any jpgs do not work. It's not a problem with that one jpg file, because I tried it here (http://www.magitek.nu/ode2ff/index2_1.php?ode=ff1_merch) as well and it does not work...
if anyone has any information on this to help, I will be very greatful. This is driving me insane, lol. thanks! =)