0

<?php include 'stats.php'; ?>在我的网站上的每个页面上都有一个。在stats.php文件中有一个 SQL 插入查询,它将数据插入到我数据库中的表中。

出于某种原因,当只访问一页时,它会在数据库中插入 4 行 - 只有一个 SQL 命令。

为什么会这样做......下面是stats.php文件上的所有代码

<?php
   $activity_history_sql=
      "INSERT into user_activity_history (user_seq, user, timestamp, ip_address, user_request_uri, 
              user_script_filename, user_script_uri, user_script_url, user_script_name, user_php_self) 
       values ('".$_SESSION["domain.co.uk"]["sequence"]."', 
             '".$_SESSION["domain.co.uk"]["forename"].' '.$_SESSION["domain.co.uk"]["surname"]."', 
             '".date("Y-m-d H:i:s")."', 
             '".$_SERVER["REMOTE_ADDR"]."', 
             '".$_SERVER["REQUEST_URI"]."', 
             '".$_SERVER["SCRIPT_FILENAME"]."', 
             '".$_SERVER["SCRIPT_URI"]."', 
             '".$_SERVER["SCRIPT_URL"]."', 
             '".$_SERVER["SCRIPT_NAME"]."', 
             '".$_SERVER["PHP_SELF"]."') ";
    $activity_history_rs=mysql_query($activity_history_sql,$conn) or die(mysql_error());
?>
4

3 回答 3

0

Please use require_once() when including stats.php.

The require_once statement is identical to require except PHP will check if the file has already been included, and if so, not include (require) it again.

于 2013-08-18T16:06:39.317 回答
0

Try different method for include like require_once('stat.php');

... that might solve your issue...

This script doesnt seem faulty.

于 2013-08-18T16:07:18.687 回答
0

好的 - 它现在似乎正在工作。可能是我的缓存没有正确刷新。也许它仍在使用 include 而不是 require_once

于 2013-08-18T16:32:05.507 回答