php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16634 Mysql query executed two times, although called only once
Submitted: 2002-04-16 10:45 UTC Modified: 2002-04-17 00:23 UTC
From: avaly at rol dot ro Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.1.2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: avaly at rol dot ro
New email:
PHP Version: OS:

 

 [2002-04-16 10:45 UTC] avaly at rol dot ro
I have the following script: 

function log_query($q) {
    echo $q."<br/>\n";
    return mysql_db_query('logs', $q);
}

global $REMOTE_ADDR, $HTTP_USER_AGENT, $HTTP_SESSION_VARS;
$agent = addslashes($HTTP_USER_AGENT);
$logged_user = $HTTP_SESSION_VARS['userinfo']['username'];

$query = "update ichb_hits set count = count + 1 where ip = '$REMOTE_ADDR' and user = '$logged_user' and agent = '$agent' and
 date > (now() - INTERVAL 1 HOUR)";
$res = log_query($query);
if (@mysql_affected_rows() <= 0) {
    $query = "insert into ichb_hits (ip, count, date, user, agent) values ('$REMOTE_ADDR', 1, now(), '$logged_user', '$agent
')";
    log_query($query);
}

This script is in a file called 'log.php'; I include this log.php only once. The update query is displayed only once, but the count increases two times; not by 2, but two times at an interval of a quarter of a second.

Configure Command : './configure' '--with-mysql' '--with-gd' '--with-zlib' '--with-apxs' 
Try http://db.lumina.ro/info.php for details about PHP installation.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-17 00:23 UTC] sniper@php.net
This is most likely the same thing as here:

http://bugs.php.net/bug.php?id=10599&edit=1

Reopen if this is not the case.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 16 22:00:02 2025 UTC