[PHP-DEV] PHP 4.0 Bug #7687: Another not a valid postgresql index From: mrbig <email protected>
Date: 11/07/00

From: mrbig <email protected>
Operating system: Debian 2.2
PHP version: 4.0.3pl1
PHP Bug Type: PostgreSQL related
Bug description: Another not a valid postgresql index

Another the same problem, I've tried to write a script that cleanly reproduces what happened:

<?
   $dblocation="localhost";
   $dbname="mydb";

function TryHere () {
   global $dblocation, $dbname;
   $database=pg_Connect($dblocation,"","",$dbname);
   $datein=pg_exec($database,"select datetime 'now';");
   pg_Close($database);
   $file=fopen('/tmp/some.file.txt','r');
   if (pg_NumRows($datein)) {
      $row=pg_Fetch_Array($datein,0);
      echo "Date is: $row[0]<br>\n";
   }
   fclose($file);
   #
   # Everything worked fine
   #
}

function TryHereAgain () {
   global $dblocation, $dbname;
   $database=pg_Connect($dblocation,"","",$dbname);
   $datein=pg_exec($database,"select datetime 'now';");
   pg_Close($database);
   if (pg_NumRows($datein)) {
      $row=pg_Fetch_Array($datein,0);
      echo "Date is: $row[0]<br>\n";
   }
   #
   # Mmm... Not anymore :(
   #
}

   TryHere();
   TryHereAgain();
?>

If I ommit to open a file, or to use any of the pg_NumRows or pg_Fetch_Array at the first call of the routine everything is ok. Also if I do the same things, but without functions. Quite interesting...

-- 
Edit Bug report at: http://bugs.php.net/?id=7687&edit=1

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>