blufish Posted August 5, 2008 Share Posted August 5, 2008 on the part of this code where it checks if file exists (which it does) it doesn't do what it's supposed to. <?php function showgarfield() { $month = $_GET['month']; $year = $_GET['year']; $syear = substr($year,-2); echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; if (file_exists('http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif')) { echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; } } showgarfield(); ?> Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/ Share on other sites More sharing options...
asmith Posted August 5, 2008 Share Posted August 5, 2008 what is the output for "echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif';" ? have you tried put this output to a browser address bar to see what happens ? Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608381 Share on other sites More sharing options...
blufish Posted August 5, 2008 Author Share Posted August 5, 2008 what is the output for "echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif';" ? have you tried put this output to a browser address bar to see what happens ? Yes, I have and it does it right and the file does exist. Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608383 Share on other sites More sharing options...
blufish Posted August 5, 2008 Author Share Posted August 5, 2008 <?php $month = $_GET['month']; $year = $_GET['year']; $syear = substr($year,-2); echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; if (file_exists('http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif')) { echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; } ?> I changed the code, it still doesn't work... Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608389 Share on other sites More sharing options...
asmith Posted August 5, 2008 Share Posted August 5, 2008 if there's no problem, Can you give me the full url of this image? Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608392 Share on other sites More sharing options...
blufish Posted August 5, 2008 Author Share Posted August 5, 2008 http://images.ucomics.com/comics/ga/2008/ga080731.gif it's a garfield comic, it's just that the part where it check if the file exists doesn't work, the code is supposed to display garfield comics. Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608393 Share on other sites More sharing options...
asmith Posted August 5, 2008 Share Posted August 5, 2008 change it to this to see what's the problem : <?php $month = $_GET['month']; $year = $_GET['year']; $syear = substr($year,-2); echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; $url = 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; if (file_exists($url)) { echo 'http://images.ucomics.com/comics/ga/'.$year.'/ga'.$syear.$month.'31.gif'; } else { echo "this $url cant be found"; } ?> Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608396 Share on other sites More sharing options...
blufish Posted August 5, 2008 Author Share Posted August 5, 2008 http://images.ucomics.com/comics/ga/2008/ga080731.gifthis http://images.ucomics.com/comics/ga/2008/ga080731.gif cant be found Does it matter that this website isn't my website? Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608397 Share on other sites More sharing options...
asmith Posted August 5, 2008 Share Posted August 5, 2008 Yea, true. I tested it on my own, and it can't find it there too. check http://ir.php.net/manual/en/function.file-exists.php for similar functions. Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608403 Share on other sites More sharing options...
abdfahim Posted August 5, 2008 Share Posted August 5, 2008 http://images.ucomics.com/comics/ga/2008/ga080731.gifthis http://images.ucomics.com/comics/ga/2008/ga080731.gif cant be found Does it matter that this website isn't my website? I think so. Because PHP is a server side language and it knows nothing other than the server it is installed. So, I guess you cannot check whether any file exists in other PC using PHP. Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608404 Share on other sites More sharing options...
blufish Posted August 5, 2008 Author Share Posted August 5, 2008 http://images.ucomics.com/comics/ga/2008/ga080731.gifthis http://images.ucomics.com/comics/ga/2008/ga080731.gif cant be found Does it matter that this website isn't my website? I think so. Because PHP is a server side language and it knows nothing other than the server it is installed. So, I guess you cannot check whether any file exists in other PC using PHP. I'm not checking another PC I'm checking if an online file can be found. Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608405 Share on other sites More sharing options...
abdfahim Posted August 5, 2008 Share Posted August 5, 2008 same thing yaar ... u r checking about a file which is hosted in another PC. Link to comment https://forums.phpfreaks.com/topic/118214-file_exists-problem/#findComment-608413 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.