php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29180 Client crash
Submitted: 2004-07-15 11:03 UTC Modified: 2005-03-06 20:46 UTC
From: tila at home dot nl Assigned:
Status: Not a bug Package: PostgreSQL related
PHP Version: 5.0.4-pre OS: Linux 2.4.24
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: tila at home dot nl
New email:
PHP Version: OS:

 

 [2004-07-15 11:03 UTC] tila at home dot nl
Description:
------------
The client crash on the following code when offset > 0;
I don't get an error message.





Reproduce code:
---------------
  $result = $db->query($QUERY);
  $total = $result->numRows();
  $back = max (0, $offset - $perpage);
  $forward = min (($offset + $perpage), max (0, (($perpage * ceil ($total / $perpage)) - $perpage)));
  $end = max (0, (($perpage * ceil ($total / $perpage)) - $perpage));
   
  $overviewtemplate->setVariable("back", $back);
  $overviewtemplate->setVariable("forward", $forward);
  $overviewtemplate->setVariable("end", $end);
 
  for ($i = $offset; (($i < $total) && ($i < ($offset + $perpage))); $i++) {
    $row = $result->fetchRow(DB_FETCHMODE_ASSOC, $i);
    while (list($key, $value) = each($row)) {
      $row[$key] = stripslashes(trim($row[$key]));
    } 
  }


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-16 00:40 UTC] tila at home dot nl
new code, I am sorry. I cannot provide a link to the server. 
open it with ?id=5 as parameter. 

<?php
require_once ('DB.php');
$dsn = "pgsql://apache:apache@localhost/groupware";
$db = DB::connect($dsn, true);
$QUERY = "SELECT o.* FROM personoverview o";
 
$result = $db->query($QUERY);
$total = $result->numRows();
$offset = $_GET['id']?$_GET['id']:0; $perpage = 10;
 
for ($i = $offset; (($i < $total) && ($i < ($offset + $perpage))); $i++) {
  $row = $result->fetchRow(DB_FETCHMODE_ASSOC, $i);
}
 
echo $offset;
?>
 [2004-07-16 00:59 UTC] tularis@php.net
does it also crash when NOT using the PEAR::DB class?
 [2004-07-16 10:34 UTC] tila at home dot nl
No, When I remove the PEAR::DB class and the code that's using it, it will display '5' just as expected.

When I use pg_exec and pg_fetch_row etc.. the result displays '42' ???? 

<?php
$db = pg_connect("host=localhost user=apache password=apache dbname=groupware");$QUERY = "SELECT o.* FROM personoverview o";
$result = pg_exec($QUERY);
$total = pg_numrows($result);
$offset = $_GET['id']?$_GET['id']:0;
$perpage = 10;
 
for ($i = $offset; (($i < $total) && ($i < ($offset + $perpage))); $i++) {
  $row = pg_fetch_row($result, $i);
}
 
echo $offset;
?>
 [2004-07-18 00:33 UTC] tila at home dot nl
42 by the way is the number of records in the database. So $offset takes the value of $total
 [2004-12-29 23:54 UTC] tila at home dot nl
php5-STABLE-200412231730

tried this one, it still returns 42, can I do something else to help you solve it, with some debugger or so?
 [2004-12-30 18:10 UTC] tila at home dot nl
When I add a line in the script so that it reads:

<?php
$db = pg_connect("host=localhost user=apache password=apache
dbname=groupware");$QUERY = "SELECT o.* FROM personoverview o";
$result = pg_exec($QUERY);
$total = pg_numrows($result);
$offset = $_GET['id']?$_GET['id']:0;
$temp_offset = $offset
$perpage = 10;
 
for ($i = $offset; (($i < $total) && ($i < ($offset + $perpage))); $i++)
{
  $row = pg_fetch_row($result, $i);
}
 
echo $offset;
?>

The result will display 5. Strange
 [2005-03-06 20:46 UTC] sniper@php.net
No crash -> no bug. (and with give information impossible to reproduce if there even was one.) Looks more like user error..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC