我有以下脚本(counter.PHP):
PHP
$conn = MysqL_connect("localhost","myuser","mypass");
MysqL_select_db("test");
$sql = "SELECT views FROM members WHERE mid = " . $_GET['mid'];
$result = MysqL_query($sql);
if (!$result)
{
mail(ADMIN,'Cannot Get: ' . MysqL_error(),MysqL_error());
}
while ($row = MysqL_fetch_assoc($result))
{
$count = $row['views']++;
}
$query = "UPDATE members SET views = '$count' WHERE mid = " . $_GET['mid'];
MysqL_query($query);
MysqL_close($conn);
// show the logo using header() and readfile(); // that part work
?>
D B:
CREATE TABLE `members` (
`mid` int(11) NOT NULL AUTO_INCREMENT,`views` int(11) DEFAULT '0',/* etc...*/
PRIMARY KEY (`mid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
现在,我在.htaccess文件中所做的是:
RewriteEngine On
RewriteRule ^img/logo([0-9]+).jpg$/counter.PHP?mid=$1 [L]
但由于某种原因,我的计数器不正确.我错过了什么?
最佳答案
原文链接:https://www.f2er.com/mysql/434267.html