MySQL query not working!

From: Date: Wed, 31 Mar 2010 11:50:07 +0000
Subject: MySQL query not working!
Groups: php.general 
Request: Send a blank email to php-general+get-303660@lists.php.net to get a copy of this message
Hi there, Here is a snippet of code... that doesn't work for some reason. Please note that I have put some @mysql_query($query) or die(mysql_error()); statements, to see if MySQL gives an error. I receive nothing other than the file starting to download. This is supposed to be a file download counter: [code] <?php //connect to the DB mysql_connect() //There is no problem with the connection so I didn't include the complete code. //The table where the hits are stored. $table = "files"; $query = "select * from " . $table . " where filename = '" . $_GET['file'] . "'"; $result = mysql_query($query); if ($result) //Has the file previously been added? { $query = "update " . $table . " set hits = hits + 1 where filename = '" . $_GET['file'] . "'"; @mysql_query($query) or die(mysql_error()); header('location:http://www.qwitter-client.net/' . $_GET['file']); } else //it's the first time we're adding this file to the DB. { $query = "insert into " . $table . " (filename, hits) values ('" . $_GET['file'] . "', 1)"; @mysql_query($query) or die(mysql_error()); header('location:http://www.qwitter-client.net/' . $_GET['file']); } ?>

« previous php.general (#303660) next »