| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Nov 2005
Posts: 57
|
echo url
Hello, I'm trying to store URLs in MySql but instead of the URL going in, all the html for the page the URL points to goes in instead, similarly if try and echo the URL the page is echoed instead. Have searched but cannot find an answer. Me code is below, the bottom part is where $URL is the part i'm refering to. Ta in advance. <?php $database= "birds"; $user = "root"; $password = ""; mysql_connect(localhost,$user,$password); @mysql_select_db($database) or die( "Unable to select database"); //get page contents $page = file_get_contents("http://www.jagprops.co.uk"); //find urls in $page, matches are put in $matches preg_match_all ("/href=[\"']?([^\"' >]+)/", $page, $matches); $count = count($matches[0]); for ( $counter = 0; $counter <= $count; $counter++){ $link = $matches[0][$counter]; $link = preg_replace( "/href=[\"']/","", $link); $link = preg_replace( "/href=/","", $link); if(!(($link[0] == 'h') || ($link[0] == 'H') || ($link[0] == '/'))) { $link = '/'.$link; echo "$link<br/>"; } else{ echo "$link<br/>"; } $URL = $page.$link; mysql_query("INSERT INTO red (url) VALUES ('$URL') ") or die(mysql_error()); } ?> |
|
|
|
![]() |