On the second page I take the URLID and look it up in a mysql db to update the clickcount field and retrieve the real URL and then I "header(location:)" them to the correct site. I keep getting an error of:
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"
I think this is inaccurate as line one is "<?php" Also if I change my $URLID var in the
Code: Select all
$result = mysql_query("SELECT * FROM linkcount WHERE ID = $URLID") or die(mysql_error());PHP Version: 4.3.11
Display Errors: Off
Error Level: E_ALL
Register Globals: Off
Code: Select all
<?php
//* declare connection variables */
$DBhost = "localhost";
$DBuser = "user";
$DBpass = "password";
$DBName = "dbname";
$table = "linkcount";
$conn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
if (!$conn) {
die('Could Not Connect: ' . mysql_error());
}
//echo 'Connected Successfully';
mysql_select_db("$DBName") or die("Unable to select database $DBName");
$result = mysql_query("SELECT * FROM linkcount WHERE ID = $URLID") or die(mysql_error());
//get results from first and hopefully only, entry
while ($row = mysql_fetch_array($result)) {
$tmpCount = $row['HitCount'] + 1;
mysql_query("UPDATE linkcount SET HitCount = ".$tmpCount." WHERE ID = ".$row['ID']) or die(mysql_error());
header("Location: http://" . $row['URL']);
}
//mysql_close();
?>