Old 03-08-2006, 15:11   #1 (permalink)
Skidzy McFergus
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());

}
?>
  Reply With Quote
Old 04-08-2006, 08:01   #2 (permalink)
Skidzy McFergus
Registered User
 
Join Date: Nov 2005
Posts: 57
ignore this post, i've been a complete tit and failed to read my own code properly.
  Reply With Quote
Old 04-08-2006, 08:12   #3 (permalink)
MikeMackay
Everything is fine.
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Witham & London
Posts: 771
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
Quote:
Originally Posted by Skidzy McFergus
ignore this post, i've been a complete tit and failed to read my own code properly.
Welcome to the world of Web Development ! You'll find you get those days.

- Mike
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8