9homie Posted June 8, 2008 Share Posted June 8, 2008 hello. Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Map Code</title> </head> <body> <?php $pokemon = array("Rattata", "Pidgey" ); $chance = rand(1, 15); $pokemon_chance = array_rand($pokemon); if(empty($_GET['start'])){ echo "<a href='{$_SERVER['PHP_SELF']}?start=1'><img src='pallettown.jpg' border='0' /></a>"; } elseif ($chance >=1 && $chance <=6 && $pokemon_chance == "Rattata") { echo "<img src='Pallet_town.png' border='0' />"; echo "You just found a Rattata"; echo "<img src=\"/pokemon images/Rattata.png\" />\n"; echo "<br />\n"; echo "<input type=\"submit\" value=\"Capture\" name=\"capture\">\n"; echo "<input type=\"submit\" value=\"Battle\" name=\"battle\">\n"; } elseif ($chance >=1 && $chance <=6 && $pokemon_chance == "Pidgey") { echo "<img src='Maps/Pallet_town.png' border='0' />"; echo "You just found a Pidgey"; echo "<img src=\"/pokemon images/Pidgey.png\" />\n"; echo "<br />\n"; echo "<input type=\"submit\" value=\"Capture\" name=\"capture\">\n"; echo "<input type=\"submit\" value=\"Battle\" name=\"battle\">\n"; } else { echo "Sorry, you did not catch a Pokemon"; } ?> </body> </html> Where it says: echo "<a href='{$_SERVER['PHP_SELF']}?start=1'><img src='pallettown.jpg' border='0' /></a>"; It is not working. I need the image to work. The image is in the same file and everything. Does there need to be any /'s or \'s in the code? Or anything else wrong with it? Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/ Share on other sites More sharing options...
pocobueno1388 Posted June 8, 2008 Share Posted June 8, 2008 The code looks fine. Are you sure the image is in the same directory? Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560468 Share on other sites More sharing options...
9homie Posted June 8, 2008 Author Share Posted June 8, 2008 yes. should it be like something like this: <img src =\"pallettown.jpg\"> ? Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560472 Share on other sites More sharing options...
retro Posted June 8, 2008 Share Posted June 8, 2008 1. Is it the same picture that would display where it echos "You just found a Rattata"? 2. Does the picture show up there? If yes to the above, note that you are using pallettown.jpg where it does not work, but Pallet_town.jpg where it works! Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560475 Share on other sites More sharing options...
9homie Posted June 8, 2008 Author Share Posted June 8, 2008 It doesn't work with either one... Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560477 Share on other sites More sharing options...
pocobueno1388 Posted June 8, 2008 Share Posted June 8, 2008 Try Pallet_town.png Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560479 Share on other sites More sharing options...
9homie Posted June 8, 2008 Author Share Posted June 8, 2008 Did and still doesn't work... Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560481 Share on other sites More sharing options...
pocobueno1388 Posted June 8, 2008 Share Posted June 8, 2008 The only reason I can see this not working is if your images are NOT in the same directory, or you are misspelling the filename. Make sure the images are in the SAME folder as the script. Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560484 Share on other sites More sharing options...
GingerRobot Posted June 8, 2008 Share Posted June 8, 2008 By doesn't work, do you mean you have a 404 error? E.g. box with a red cross it in? What does the source look like when you view it? Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560485 Share on other sites More sharing options...
MiCR0 Posted June 8, 2008 Share Posted June 8, 2008 echo "<a href='".$_SERVER['PHP_SELF']."?start=1'><img src='pallettown.jpg' border='0' /></a>"; Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560488 Share on other sites More sharing options...
9homie Posted June 8, 2008 Author Share Posted June 8, 2008 Because i use a iMac i have a blue box with a question box in. Go to: http://pokemonoracle.web44.net/mapcode.php/ and you can see what is going wrong. If you do see the pik. It is just some random one Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560489 Share on other sites More sharing options...
retro Posted June 8, 2008 Share Posted June 8, 2008 Try Pallet_town.png Sorry, that's what I meant. Agreed, this should work. I would imagine it is a file location problem, e.g.: If this script is: ./script.php then the picture would need to be: ./pallettown.jpg or if the script is: ./subdir/script.php then the picture would be: ./subdir/pallettown.jpg If you're on a Linux server, it may bitch about case too - make sure it isn't .JPG instead of .jpg. I would personally use double quotes for an img src location, but the single one should work. Do the pokemon images work? Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560493 Share on other sites More sharing options...
crapol Posted June 8, 2008 Share Posted June 8, 2008 Looks all most like the facebook app Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560497 Share on other sites More sharing options...
AndyB Posted June 8, 2008 Share Posted June 8, 2008 I don't see the image. Either there's no such image on your server or the image is not where you (and your code) think it is. Link to comment https://forums.phpfreaks.com/topic/109269-solved-image-not-working/#findComment-560498 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.