[phplib] bug in ct_sql.inc From: Daniel Sadilek (d.sadilek <email protected>)
Date: 12/13/00

Hi,

i think there's a bug in ct_sql in function ac_store().

I use phplib 7.2c and mysql 3.23.27b and php 4.0.3pl1.

The bug:
========

When I use page_close() when no data has been changed i get this error:
... Invalid SQL: insert into active_sessions ... double entry for key 1
...

The fix:
========

original:
$squery = sprintf("select count(*) from %s where val='%s' and
changed='%s' and sid='%s' and name='%s'",

fixed:
$squery = sprintf("select count(*) AS row_count from %s where val='%s'
and changed='%s' and sid='%s' and name='%s'",

original:
    if ( $this->db->affected_rows() == 0
        && $this->db->query($squery)
        && $this->db->f(1) == 0
        && !$this->db->query($iquery)) {

fixed:
    if ( $this->db->affected_rows() == 0
        && $this->db->query($squery)
        && $this->db->next_record()
        && $this->db->f('row_count') == 0
        && !$this->db->query($iquery)) {

Daniel Sadilek

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>