Edit: RESOLVED: See next post
I can't get a download-counter script I made to work.
I can get it to redirect to the file, but it's not updating the row... I'm probably overlooking something very simple...
PHP Code:
<?php
if(isset($_GET['f'])){
mysql_connect("localhost", "USER", "PASS");
mysql_select_db("DB");
$getf = $_GET['f'];
$sql = mysql_query("SELECT * FROM `downloads` WHERE `name` = '$getf'");
$numrows = mysql_num_rows($sql);
if($numrows == 1){
$sql = mysql_query("SELECT * FROM `downloads` WHERE `name` = '$getf'");
while($rs = mysql_fetch_array($sql)) {
$num = $rs[0] + 1;
}
mysql_query("UPDATE downloads WHERE `name`='$getf' SET `hits` = '$num'");
header("location: wp-content/uploads/".$getf);
}
else{
mysql_query("INSERT INTO `downloads` VALUES('$getf', '1')");
header("location: wp-content/uploads/".$getf);
}
}
else {
echo 'No file specified!';
}
?>
Here's the table structure (from PHPMyAdmin):

Thanks,
X96
Bookmarks