php 计数器问题,请看以下程序,错在哪里?

来源:百度知道 编辑:UC知道 时间:2024/06/06 05:30:44
<?php
//-----[基本设定]------
$mysql_server_name="localhost";
$mysql_username="a0513181735";
$mysql_password="43570057";
$mysql_database="a0513181735";
//---------
//建立连线----透过(伺服器位置,使用者名称,使用密码)
$ip=$_SERVER['REMOTE_ADDR'];
$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

//SQL语法
$sql = "select TIME_TO_SEC ( now () - time_at ) from dy2008 where 'ip' = '"$ip"' and name = 'tlone' order by time_at desc";
//选取你要处理的数据库
mysql_select_db($mysql_database,$conn);
//进行查询或者执行....
$result=mysql_query($sql);
//获取第一笔资料
$row=mysql_fetch_row($result);
//结束并且释放连线
$timeout = $row[0];
mysql_close($conn);
//--------------------------------------------
//判断是不是灌水,如过超过设定时间则插入一个数据
if($timeout>5)

我看你的程序的意思好像是:
对在一定时间内对同一个账号不同ip来得到访问总数对么??

第13行:
$sql = "select TIME_TO_SEC ( now () - time_at ) from dy2008 where 'ip' = '"$ip"' and name = 'tlone' order by time_at desc";

where 'ip' = '"$ip"' and name = 'tlone'
修改成
where ip = '".$ip."' and name = 'tlone'

字段名不能加引号或加后引号``, 字符要以.连接!

不过现在的都是ADSL上网,每次ip拨号都随机分配,好像不ip判断不太好吧,还是只用用户名吧!

另数据库连接在同一页面只需要连接一次就行了