PHPLIB and postgresql

Can some one pls tell me why i get this with :
redhat 6,mod_php0.9;modphpimap0.9;modphppgsql0.9 and phplib (latest)

PHP works fine database access works fine sessions seem to work (almost)
but I get the following error on every page :


Warning: This compilation does not support pg_cmdtuples() in db_pgsql.inc on line 122

Warning: PostgresSQL query failed: ERROR: Cannot insert a duplicate key into a unique index in db_pgsql.inc on line 52
Database error: Invalid SQL: insert into active_sessions ( sid, name, val, changed ) values ('821b6c41882e2148431ffa52ba56e561', 'Example_Session', 'RXhhbXBsZV9TZXNzaW9uOiR0aGlzLT5pbiA9ICcnOyAkdGhpcy0+cHQgPSBhcnJheSgpOyAkdGhpcy0+cHRbJ3MnXSA9ICcxJzsgJHRoaXMtPnB0WydhdXRoJ10gPSAnMSc7ICRHTE9CQUxTWydzJ10gPSAnMyc7ICRHTE9CQUxTWydhdXRoJ10gPSBuZXcgRXhhbXBsZV9EZWZhdWx0X0F1dGg7ICRHTE9CQUxTWydhdXRoJ10tPmF1dGggPSBhcnJheSgpOyAkR0xPQkFMU1snYXV0aCddLT5hdXRoWyd1aWQnXSA9ICdmb3JtJzsgJEdMT0JBTFNbJ2F1dGgnXS0+YXV0aFsncGVybSddID0gJyc7ICRHTE9CQUxTWydhdXRoJ10tPmF1dGhbJ2V4cCddID0gJzIxNDc0ODM2NDcnOyAkR0xPQkFMU1snYXV0aCddLT5hdXRoWydyZWZyZXNoJ10gPSAnMjE0NzQ4MzY0Nyc7ICRHTE9CQUxTWydhdXRoJ10tPmF1dGhbJ3VuYW1lJ10gPSAna3Jpcyc7IA==', '20000107092418')
PostgreSQL Error: 1 (ERROR: Cannot insert a duplicate key into a unique index )
Session halted.
castleinfoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

maxkirCommented:
The problem is that in this line:

Warning: This compilation does not support pg_cmdtuples() in db_pgsql.inc on line 122

It looks like your compilation of modphppgsql0.9 does not support function pg_cmdtuples(). I have no idea why.
So because of that affected_rous function returns 0 instead of 1 and tryes to do another insert.

Possible workaround:
editt file ct_sql.inc in php-lib and add this line:
$old_err_rep = error_reporting(0);
before line which contains:
if (  $this->db->affected_rows() == 0
(for me it is line 91)

and add this:
error_reporting($old_err_rep); after

$old_err_rep = error_reporting(0);
if (  $this->db->affected_rows() == 0
      && !$this->db->query($iquery)) {
        $ret = false;
}
error_reporting($old_err_rep);

This should remove warnings, but code will work anyway.
0
castleinfoAuthor Commented:
Thanks, I was thinking along the same lines and so tried the 0.12 versions of mod_php3 etc.. But this gave an error with apache on start, So I unistalled went back to 0.9 and tried you fix. Yes it gets rid of the cmd_tuples error but I still get the rest of the error:

Per Session Data: 3

Per Session Data is referenced by session id. The session id is propagated using either a cookie stored in the users browser or as a GET style parameter appended
to the current URL.

Per Session Data is available only on pages using the feature "sess" in their page_open() call. Database error: Invalid SQL: insert into active_sessions ( sid, name,
val, changed ) values ('d10ff08ba6b53aa56e705abaa824d24b', 'Example_Session',
'RXhhbXBsZV9TZXNzaW9uOiR0aGlzLT5pbiA9ICcnOyAkdGhpcy0+cHQgPSBhcnJheSgpOyAkdGhpcy0+cHRbJ3MnXSA9ICcxJzsgJEdMT0JBTFNbJ3MnXSA9ICczJzsg',
'20000110042848')
PostgreSQL Error: 1 (ERROR: Cannot insert a duplicate key into a unique index )
Session halted.

Any ideas ?
0
maxkirCommented:
Replace this code in ct_sql.inc:

$this->db->query($uquery);
if (  $this->db->affected_rows() == 0
     && !$this->db->query($iquery)) {
       $ret = false;
}

with this:

$this->db->query(sprintf("SELECT count(*) from %s where sid='$id' AND name='$name'", $this->database_table));
if (!this->db->num_rows())
{
    $this->db->query($iquery);
}
else
{
    $this->db->query($uquery);
}

Hope, this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

maxkirCommented:
Did my comment help you ?
0
castleinfoAuthor Commented:
Sorry I gave up for a short while.. Yes the changes cleared the tuples error, but now the session counter doesn't actualy update !

http://www.castleinfo.co.uk/index.php3

I added some echo's to check the session variable. (hence the stuff at the bottom of the screen.)

Any more ideas ? It's odd because I have IMP running now (as of two days ago) and that uses phplib.

Should I try an older version of PHPLIB that may work with my current rpms ?

Thanks for the help so far.
0
maxkirCommented:
Try to remove error_reporting lines I suggested to add before - I suggest there is a problem with SQL call now ...

0
castleinfoAuthor Commented:
This is the current modification :

## Next line of code provided by maxkir on experts exchange
##      $old_err_rep = error_reporting(0); ##remove error codes

$this->db->query(sprintf("SELECT count(*) from %s where sid='$id' AND
 name='$name'", $this->database_table));        if (!$this->db->num_rows())
      {
            
          $this->db->query($iquery);
      }
      else
      {
            
          $this->db->query($uquery);
       }
##      error_reporting($old_err_rep); ##turn them back on
      
    return $ret;
  }

0
castleinfoAuthor Commented:
Thanks for your help, apparently you can get cmd_tuples to work if you recompile the source etc.. but now I've already written my own session handling code that works with cookies and MD5 passwords fine...
No harm giving you the points though !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.