php 计数器

来源:百度知道 编辑:UC知道 时间:2024/06/30 16:59:09
<?
//新增资料

//初始化
$name="localhost";
$user="root";
$password="";
$mysql_database="jsq";
$ip=getenv('remote_addr');
//防灌水计数
//SELECT************************************
$connect=mysql_connect($name,$user,$password);

//准备好sql语句
$sql="select * from `counter`while ip='$ip' and name='11' ";

//进行查询
$result=mysql_db_query($mysql_database,$sql,$connect);

//查询的结果--->抓出一笔
$row=mysql_fetch_row($result);

//映出资料
print_r($row);

//清楚查询结果
mysql_free_result($result);

if($row)
{
//建立链接
$connect=mysql_connect($name,$user,$password);

//准备好sql语句
$sql="select time_to_time_sec(now())-time_to_time_sec(time) from `counter`where ip='$ip' and new='11' order by 'time_to_time_sec(now())-time_to_t

这个错误是指存在标点符号错误

你把这个php文件放到editplus等php编辑工具里
就会看到
你从35行开始的某个引号没有结束,导致后面的全部都包含在引号里了……
'time_to_time_sec(now())-time_to_time sec(time)';
改成
'time_to_time_sec(now())-time_to_time sec(time)' ";