GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech One more quick question, click counting (https://gfy.com/showthread.php?t=1356875)

Publisher Bucks 08-08-2022 08:58 PM

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? :helpme

LaSexorcisto 08-08-2022 10:58 PM

This is how PHP got labeled as a shitty unsecured language that's easy to hack. I've been defending the language for 15+ years saying its not the language that's bad.

Klen 08-08-2022 11:58 PM

Did you tested first query in database over tool like phpmyadmin ?

k0nr4d 08-09-2022 12:18 AM

Ignoring all the SQL injection etc,

UPDATE Directory SET Clicks = count + 1 WHERE ID = '$link'
should be
UPDATE Directory SET Clicks = Clicks + 1 WHERE ID = '$link'


All times are GMT -7. The time now is 05:40 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc