d22552000 Posted October 27, 2007 Share Posted October 27, 2007 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... Quote Link to comment Share on other sites More sharing options...
marcus Posted October 27, 2007 Share Posted October 27, 2007 mysql_query("UPDATE `table` SET `Downloads`=`Downloads`+1 WHERE `ID`='$B'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 no error, warning, or notice returned. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 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) Quote Link to comment Share on other sites More sharing options...
unidox Posted October 27, 2007 Share Posted October 27, 2007 use ++ not +1 Quote Link to comment Share on other sites More sharing options...
marcus Posted October 27, 2007 Share Posted October 27, 2007 use ++ not +1 ++ equals +1 Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 ++ does the same thing.... SET `downloads`++ Quote Link to comment Share on other sites More sharing options...
marcus Posted October 27, 2007 Share Posted October 27, 2007 `filepirate`.`FILES` Why not just `filepirateFILES` or is it defined? If it's defined get rid of the `'s Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 no, i am workking on different db's at once so I never used SELECT_DB `filepirate`.`FILES` this code will select table `FILES` in db `filepirate` Quote Link to comment Share on other sites More sharing options...
marcus Posted October 27, 2007 Share Posted October 27, 2007 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()); Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 I know, but htis is much SMALLER code as you have noticed. It is what im used to. It is not a bad coding practice, but its not organized either. Its not depricated and yet its not fully recommended. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 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! Quote Link to comment Share on other sites More sharing options...
d22552000 Posted October 27, 2007 Author Share Posted October 27, 2007 ok I finally fixed it, this code worked: UPDATE `filepirate`.`FILES` SET `Downloads`=`Downloads`+1 WHERE `ID`=$ID Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.