I can not figure out why the hell this isn't working please help me.....
this is the error i keep getting:
Warning: Cannot modify header information - headers already sent by (output started at /home/scrypte/public_html/link/linkout.php:8) in /home/scrypte/public_html/link/linkout.php on line 46
<?php
$dbHost =localhost; #Your db host
$dbUser =username; #username
$dbPass =pass; #Pass
$dbname =database; #Name of the database.
$db = mysql_connect("$dbHost","$dbUser","$dbPass");
mysql_select_db($dbname,$db);
?>
<?php
#include database variables
$requete = "SELECT * FROM LinkCounter";
$result = mysql_query ($requete,$db);
while ($article = mysql_fetch_object($result))
{
echo '<table border=0 cellspacing=0 cellpadding=0 width=350 align=left><tr><td>';
echo '<a href="link.php?link='.$article->ID.'">';
echo '<img src="'.$article->image.'" align="left" border="0" alt="" style="border: 1px #404040 dotted;">';
echo '</a>';
echo '<font face="tahoma" size="1" color="#808080">';
echo '<b>'.$article->name.'</b>';
echo '<font face="verdana" size="1" color="#49B8FF"> - ';
echo '<a href="linkout.php?link='.$article->authorlink.'">'.$article->author.'</a> ';
echo '</font><br>';
echo '<font face="tahoma" size="1" color="#808080">';
echo 'Category: '.$article->category.' Views '.$article->count.'';
echo '<br>';
echo 'Description: '.$article->description.'';
echo '</tr></td></table>';
echo '<p> </p>';
}
mysql_free_result($result);
?>
<?php
function dbinsans($text) {
$text = strip_tags ($text, "");
$text = str_replace(chr(10),"",$text);
$text = str_replace(chr(13), "<br>", $text);
$text = str_replace("\"","*",$text);
$text = str_replace("'","*",$text);
$text = addslashes($text);
return($text);
}
#This function is used to check the input, a hacker could break the query
#and use his own query if we're not careful and don't check this stuff
$link=dbinsans($_GET['link']);
$db = mysql_connect("$dbHost","$dbUser","$dbPass");
mysql_select_db($dbname,$db);
$requete = "SELECT * FROM LinkCounter WHERE ID='$link'";
$result = mysql_query ($requete,$db);
#Should return only one value, our link if it exists
$article = mysql_fetch_object($result);
#Gives an object with our row back
#Gets the address of the link
#like Leo's tutorial this redirects the browser
$count = $article->count + 1;
#Gets and adds one to counter variable
$sql = "UPDATE LinkCounter SET count='$count'
WHERE ID='$link'";
#Updates count
mysql_query($sql, $db);
#Queries the database and updates the count at ID.
mysql_free_result($result);
exit();
?>
<?php
$link = $_GET['link'];
if($link == ".$article->ID."){
$redirect = '.$article->ID.address';
header("Location: $redirect");
}
?>