redarrow Posted July 4, 2008 Share Posted July 4, 2008 Advance thank you....... The problam is if you dont add the http:// the code creates http:// that correct.. but if you add as it is a http:// the code dosent use the else command or the ! command from the !eregi code and you get http://http:// <<< file_get-contens error.......... please help cheers ps.. all the code needs to do is see if there is a http:// in the url and if not add http:// <?php // get the url the link is at...... $p="http://www.faironprice.co.uk/links.php"; // if the link got http;// or uper case HTTP:// if(eregi("(http:// | HTTP://)",$p)){ // return the function......... return back_link1($p); //exit kill the process........ exit; // else if there is no http:// }else{ //replace the non http;// with a http:// $p=str_replace($p,"http://$p",$p); //return the fuction..... return back_link1($p); exit kill the process... exit; } // create a function............. function back_link1($p){ // get the url to cheek link $htmlString=file_get_contents($p); // see if the link exists.... if (eregi('http://www.office1000.org/', $htmlString)) { // found echo "Link Found!"; }else{ // not found..... echo "Link not Found"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/113191-solved-very-strange-problam-with-from-eregi/ Share on other sites More sharing options...
Daniel0 Posted July 4, 2008 Share Posted July 4, 2008 if (substr($p, 0, 7) !== 'http://') { $p = 'http://' . $p; } What about that? Quote Link to comment https://forums.phpfreaks.com/topic/113191-solved-very-strange-problam-with-from-eregi/#findComment-581559 Share on other sites More sharing options...
redarrow Posted July 4, 2008 Author Share Posted July 4, 2008 another easer example will work........ <?php $p="www.faironprice.co.uk/links.php"; if(eregi("(http:// | HTTP://)",$p)){ $htmlString=file_get_contents($p); if (eregi('http://www.office1000.org/', $htmlString)) { echo "Link Found!"; }else{ echo "Link not Found"; } exit; }else{ $p=str_replace($p,"http://$p",$p); $htmlString=file_get_contents($p); if (eregi('http://www.office1000.org/', $htmlString)) { echo "Link Found!"; }else{ echo "Link not Found"; } } ?> wont work <?php $p="http://www.faironprice.co.uk/links.php"; if(eregi("(http:// | HTTP://)",$p)){ $htmlString=file_get_contents($p); if (eregi('http://www.office1000.org/', $htmlString)) { echo "Link Found!"; }else{ echo "Link not Found"; } exit; }else{ $p=str_replace($p,"http://$p",$p); $htmlString=file_get_contents($p); if (eregi('http://www.office1000.org/', $htmlString)) { echo "Link Found!"; }else{ echo "Link not Found"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/113191-solved-very-strange-problam-with-from-eregi/#findComment-581560 Share on other sites More sharing options...
redarrow Posted July 4, 2008 Author Share Posted July 4, 2008 SOLVED........ thanks dan............. dan that solved the issue so it the eregi then....... <?php $p="www.faironprice.co.uk/links.php"; if (substr($p, 0, 7) !== 'http://') { $p = 'http://' . $p; } $htmlString=@file_get_contents($p); if (eregi('http://www.office1000.org/', $htmlString)) { echo "Link Found!"; }else{ echo "Link not Found"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/113191-solved-very-strange-problam-with-from-eregi/#findComment-581562 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.