<?php
/** Connect to DB */
mysql_connect("localhost", "dbuser", "pass") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$link_id = $_GET['link_id'];
/** increase the counter of the URL*/
mysql_query("UPDATE link_count SET count = count + 1 WHERE ID = $link_id") or die(mysql_error());
/** retrieve URL */
$result = mysql_query("SELECT * FROM link_count WHERE ID = $link_id") or die(mysql_error());
$row = mysql_fetch_array($result);
header( "Location:" .$row['URL'] );
?>
Of course db info has been changed for posting here. Where I try to use
count.php?link_id=1
in a link I get "Unknown column 'ID' in 'where clause'"
I checked to make sure there were all single quotes instead of backticks....
EDIT: Solution provided by @Kai Qing in a comment to CanSpice's answer.