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(); ?> Quote Link to comment 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 ? Quote Link to comment 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. Quote Link to comment 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... Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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"; } ?> Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. 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.