I got the last one to work ( simple outbound link tracker – Why isn't this working? ), problems were whitespace and column name capitalization.
Now I’m trying to implement this in an existing database without any luck.
Here’s the code (not including mysql connect data and obfuscating table name)
<?php
$id = $_GET['ID'];
/** Increase the counter of the URL to which the user is going*/
mysql_query("UPDATE `table_name` SET countout = countout + 1 WHERE ID = '$id'") or die(mysql_error());
/** Retrieves URL */
$result = mysql_query("SELECT * FROM `table_name` WHERE ID = '$id'") or die(mysql_error());
$row = mysql_fetch_array($result);
//redirects them to the link they clicked
header( "Location:" .$info['Url'] );
?>
And also important, here is a screenshot of the db table structure with data in it:
http://cl.ly/323A1i3L0n181P3H0J2B/Image%202012-01-05%20at%201.39.41%20PM.png
When I attempt
out.php?id=36
I get a blank page
EDIT: @Runar Jørgensen provided the fix. Just trying to secure it from SQL injection now
You have a few errors in your script that should be corrected. You should enable errors, while developing, so that you see what’s not working with your script.
First of all: Variables are case-sensitive, and if your link is
out.php?id=36then you should use$_GET['id']and not$_GET['ID'].Secondly: You’re redirecting to an unset url, as far as see. You should edit the header tag to look like this:
header("Location: " . $row['Url']);You should also be aware of SQL Injections, and read up on how to handle them.