View Single Post
Old 08-08-2022, 08:58 PM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
One more quick question, click counting

I'm *trying* to use the following code (link.php) to update a column in my db to count clicks to external links:

Quote:
<?php

/** Connect to DB */

mysqli_connect("localhost", "user", "pass", "db") or die(mysqli_error());

$link = $_GET['ID'];

/** Increase the counter of the URL to which the user is going*/

mysqli_query("UPDATE Directory SET Clicks = count + 1 WHERE ID = $link") or die(mysql_error());

/** Retrieves URL */

$result = mysqli_query("SELECT * FROM Directory WHERE ID = ID") or die(mysqli_error());

$row = mysqli_fetch_array($result);

//redirects them to the link they clicked
header( "Location:" .$row['Website'] );

?>
But its telling me that my query is incorrect, I thought I only had to update the count into the 'Clicks' column in the database?

The link.php page is just opening, with no redirect.

Do I need to do something else with the query or the database column to make this work?
__________________
NOTHING TO SEE HERE
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote