$short = $_REQUEST[ "short" ];
$mysqli = new mysqli( DB_HOST, DB_USERNAME, DB_PASSWORD, DB );
$clicks = $mysqli->query("SELECT clicks FROM leafy_urls WHERE short = '$short'")->fetch_object()->clicks;
$clicks++;
$statement = $mysqli->prepare( "UPDATE leafy_urls SET clicks=? WHERE short=?" );
$statement->bind_param('is', $clicks, $short );
$results = $statement->execute();
if( $results )
{
$long_url = $mysqli->query("SELECT long_url FROM leafy_urls WHERE short = '$short'")->fetch_object()->long_url;
Header("HTTP/1.1 301 Moved Permanently");
header("Location: " .$long_url. "");
}
else
{
//$html = "Error: Cannot find short URL";
$html = 'Error : ('. $mysqli->errno .') '. $mysqli->error;
}
$mysqli->close();
This code works to the point it doesn't throw error but the number in the database does not increase. Stays at 1