elyfrank Posted March 2, 2010 Share Posted March 2, 2010 >:(Hi guys, Maybe somebody can help me out here. I have this php file that read urls from a text file where my link should be placed. The script works fine with one link but when I add a second link I get this error:failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in check.php on line 8 RED> Missing or this one: all the links say missing. This is the script: <?php $mydomain = "www.yourwebsite.com"; // Set this to your domain $list = file_get_contents("sites.txt"); $urls = explode ("\n", $list); echo "<B>Checking back links to $mydomain....</B><P><FONT SIZE=-1>"; foreach ($urls as $url) { if (strlen ($url)) { echo $url . "<B><FONT COLOR="; if (strpos (file_get_contents($url), $mydomain) != FALSE) { echo "GREEN> Found"; } else { echo "RED> Missing"; } echo "</FONT></B><BR>"; } } echo "</FONT>"; ?> Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/ Share on other sites More sharing options...
teamatomic Posted March 2, 2010 Share Posted March 2, 2010 I'll go out on a limb and take a wild guess. You built the sites.txt file by hand and hit enter after the last line giving you a blank line with a \n in it. When you explode on the \n you in fact add a blank entry as the last element in the array. There is your error (BTW) I dont really make wild guesses HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020209 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 Good guess. That was the first thing i checked too. That is not the problem. anything else? Thanks Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020212 Share on other sites More sharing options...
teamatomic Posted March 2, 2010 Share Posted March 2, 2010 do this: and paste the output $urls = explode ("\n", $list); foreach($urls as $url) { echo "::$url::<br>"; } exit; Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020214 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 ::http://for-the-love-of-dogs.net/index.cfm?id=4214&fuseaction=browse&pageid=95 :: ::http://www.google.com :: ::http://www.yahoo.com:: Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020216 Share on other sites More sharing options...
teamatomic Posted March 2, 2010 Share Posted March 2, 2010 Simple. Google and Yahoo dont have your link in their 404 page. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020221 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 I know that. I just put those two to see if the script was working. Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020222 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 I know all these three have my link. http://for-the-love-of-dogsdotnet/index.cfm?id=4214&fuseaction=browse&pageid=95 Missing http://www.information-about-dogsdotcom/pet-links-5.html Warning: file_get_contents(http://www.information-about-dogsdotcom/pet-links-5.html ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /hermes/bosweb/check.php on line 9 RED> Missing http://pipdoggy.com/catalog/linksdotphp?lPath=10 Found I replaced .com for dotcom in case you wanted to check those pages. Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020224 Share on other sites More sharing options...
teamatomic Posted March 2, 2010 Share Posted March 2, 2010 Then it kinda works as expected?? Put the first url in a few times but alter the pageid http://for-the-love-of-dogs.net/index.cfm?id=4214&fuseaction=browse&pageid=94 http://for-the-love-of-dogs.net/index.cfm?id=4214&fuseaction=browse&pageid=93 What happens. Do you still get the 404 error? HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020225 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 Same error, They all say missing but the last one. Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020228 Share on other sites More sharing options...
teamatomic Posted March 2, 2010 Share Posted March 2, 2010 I was going over your code and something caught my eye, the if(strpos(file_get_contents line try a true !== instead of != that way only false will be true. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020230 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 Same error Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020233 Share on other sites More sharing options...
teamatomic Posted March 2, 2010 Share Posted March 2, 2010 I made a url file and eliminated the file_get_contents and it works OK if you use a true !== if (strpos($url, $mydomain) !== FALSE) so the problem lies within the use of file_get_contents in the strpos cause I tried the urls alone in a file_get_contents and they all work OK. A few ideas, add double quotes in the file_get_contents("$url") make it sleep for a few seconds in between gets of the url's. If neither of those work you might have to break the combined if apart. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020256 Share on other sites More sharing options...
elyfrank Posted March 2, 2010 Author Share Posted March 2, 2010 Teamatomic, Thanks for trying to help me. still doesn't work. this is what I got so far: <?php $mydomain = "www.yourwebsite.com"; // Set this to your domain $list = file_get_contents("sites.txt"); $urls = explode ("\n", $list); echo "<B>Checking back links to $mydomain....</B><P><FONT SIZE=-1>"; $urls = explode ("\n", $list); foreach ($urls as $url) { if (strlen ($url)) { echo $url . "<B><FONT COLOR="; sleep(10); if (strpos (file_get_contents("$url"), $mydomain) !== false) { echo "GREEN> Found"; } else { echo "RED> Missing"; } echo "</FONT></B><BR>"; } } echo "</FONT>"; ?> Link to comment https://forums.phpfreaks.com/topic/193845-reciprocal-link-checker/#findComment-1020682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.