Jump to content

[SOLVED] Very strange problam with ! from eregi


redarrow

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

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.