Jump to content

Recommended Posts

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";
}
}

?>

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";
}
}

?>

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";
}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.