Jump to content

[SOLVED] +1 not working? Download Counter


d22552000

Recommended Posts

I have a mysql call in a php function that says WHERE id=$id downloads=downloads+1 and it doesnt work:

 

        mysql_query("UPDATE `*`.`FILES` SET `Downloads`=`Downloads`+1 WHERE `files`.`ID` = '$B';");

 

Downloads only goes upto 1 and won't go over 1...

Link to comment
Share on other sites

still not updating dlcount, now it wont even come from 0 to 1 like it WAS doing..

 

FULL SOURCE:

 

<?PHP
include('./HTML/html.php');

include('../log.php');

$SELF =        $_SERVER['PHP_SELF'];
$HOST =       $_SERVER['HTTP_HOST'];
$RADD =     $_SERVER['REMOTE_ADDR'];
$RHST =     $_SERVER['REMOTE_HOST'];
$RPRT =     $_SERVER['REMOTE_PORT'];
$REFR =    $_SERVER['HTTP_REFERER'];
$REQU =    $_SERVER['REQUEST_TIME'];
$QURY =    $_SERVER['QUERY_STRING'];
$CONN = $_SERVER['HTTP_CONNECTION'];
$USAG = $_SERVER['HTTP_USER_AGENT'];

__log($SELF,$HOST,$RADD,$RHST,$RPRT,$REFR,$REQU,$QURY,$CONN,$USAG);

   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

function getfile($TYPE,$B,$PATH) {
       mysql_query("UPDATE `filepirate`.`FILES` SET `Downloads`=`Downloads`+1 WHERE `ID`='$B'") or die(mysql_error());
       $a=@file_get_contents('../dl.cnt'); $a++; @file_put_contents('../dl.cnt',$a);

       header('Content-Description: File Transfer');
       header('Content-Length: '.filesize($PATH));
       header('Content-type: '.$TYPE);

       header('Content-Disposition: attachment; filename="'.$B.'"');

       readfile($PATH);
}

function eror($RET) {
html('ERROR',$RET);
die();
}

$NAME = $_GET['id'];

       /* MYSQL CONNECTION */
       mysql_connect(localhost,'root','');
       $r = mysql_query("SELECT * FROM `filepirate`.`FILES` WHERE ID=$NAME;") or eror(mysql_error());

while(list($ID,$B,$PASS,$DESC,$TYPE,$DOWN)= mysql_fetch_row($r)) {
 $PATH = './Files/'.$ID;

 if (file_exists($PATH) && !empty($_GET['id'])) {
  if (!empty($PASS)) {
   if (!empty($_POST['pass'])) {
    if ($PASS==$_POST['pass']) {
     getfile($TYPE,$B,$PATH);
    } else { eror('Invalid Pass.  Pass Not Right'); }
   } else { eror('No Password Entered'); }
  } else { getfile($TYPE,$B,$PATH); }
 } else { eror('Invalid File.  File Not Here!'); }
}

?>

 

The type of my DOWNLOADS column in mysql is int(12)

Link to comment
Share on other sites

You can connect to more than one database and still use them in certain queries.

 

$connection1 = mysql_connect("localhost","username","password");
$dbconnect1 = mysql_select_db("databasename",$connection1);
$connection2 = mysql_connect("localhost","otherusername","otherpassword");
$dbconnect2 = mysql_select_db("otherdatabasename",$connection2);

$query1 = mysql_query("SELECT * FROM `this` WHERE `that`='something'", $dbconnect1) or die(mysql_error());
$query2 = mysql_query("SELECT * FROM `that` WHERE `something`='this'", $dbconnect2) or die(mysql_error());

 

Link to comment
Share on other sites

please help, I need this .  Then my file upload site will becomplete!  with that session problem fix I already have profiles, memebrs file owners, file sizes, downloading from and uplooading to servers / ftp servers...  Uploading from a computer with progress bar for ALL of them.  I have been working on this for a long time.

 

Just this stupid download counter thing now, then it's done!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.