Broken Links

So I started writing something like a search engine that runs through a sql database. Anything works fine except when you click on the title (Which is connected to the link of the page you want to go to) it brings you to www.“my website”/“the link” (www.example.com/Link I Want to Go To)

Source Code:

Simp - Search

Simp

' />
Results:
<?php $k = $_GET['k'];
	$terms = explode(" ",$k);
	$query = "SELECT * FROM search WHERE ";
	
	foreach ($terms as $each){
		$i++;
		if ($i == 1)
			$query .= "keyw LIKE '%$each%' ";
		else
			$query .= "OR keyw LIKE '%$each%' ";
	}
	
	// connect
	mysql_connect("localhost", "airbornz", "ltSZ8h6b83") or die("Error: Could Not Connect! Error Code 2,sql");
	mysql_select_db("airbornz_simp1") or die("Error: Could Not Connect To Database! Error Code 3,data");
	
	$query = mysql_query($query);
	$numrows = mysql_num_rows($query);
	if ($numrows > 0){
	
		while ($row =mysql_fetch_assoc($query)){
			$id = $row['id'];
			$title = $row['title'];
			$descript = $row['descript'];
			$keyw = $row['keyw'];
			$link = $row['link'];
			
			echo "<h2><a href='$link'>$title</a></h2>
		 	Catagory: $descript
			<br />
			Link: <a href='$link'>$link</a>
			<br /> <hr />";
		}
	
	}
	if ($k =''){
		echo "<b>Please Enter Something Into The Search Bar!<b>";
	}
	else
		echo "No results found for <b>\"$k<b>\"";
	
	// disconnect
	mysql_close();
	


?>

Thanks,
Cole

First of all switch to PDO or mysqli.

What is stored in the table under link?

Sponsor our Newsletter | Privacy Policy | Terms of Service