#23613 [NEW]: PHP sometimes cannot display fields by name, only by position
| From: | vhcampos at terra dot com dot br | Date: | Tue, 13 May 2003 17:49:13 +0000 |
| Subject: | #23613 [NEW]: PHP sometimes cannot display fields by name, only by position | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-39538@lists.php.net to get a copy of this message | ||
From: vhcampos at terra dot com dot br
Operating system: Windows 98
PHP version: 4.3.1
PHP Bug Type: InterBase related
Bug description: PHP sometimes cannot display fields by name, only by position
When I use the following code for the following table, PHP returns the
message:
Notice: Undefined index: name in d:\sites\index.php on line 29
when I try to echo($row["name"]) (or whatever field I try).
If I try using $row->name after a $row = ibase_fetch_object($rst), I get
the message:
Notice: Undefined property: name in d:\sites\index.php on line 39
The problem doesn't happen if the table is empty.
Interbase table:
CREATE TABLE "NAME"
(
"COD" INTEGER NOT NULL,
"NAME" VARCHAR(50) CHARACTER SET WIN1252 NOT NULL,
"DATE1" TIMESTAMP,
PRIMARY KEY ("COD")
);
PHP Example:
<?
$local_bd = "intranet:D:\Database\Projetos.gdb";
$usuario = "SYSDBA";
$senha = "masterkey";
$characterSet = "WIN1252";
$cn = ibase_connect($local_bd, $usuario, $senha, $characterSet, 0, 3)
or die("Cannot connect to database.");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
This is just a test.
<p>
<?
$sql = "select cod, name, date1 from Name order by name";
$rst = ibase_query($cn, $sql);
while ($row = ibase_fetch_row($rst))
{
echo("ID: " . $row["cod"] . "<br>\n");
echo("Name: " . $row["name"] . "<br>\n");
}
ibase_free_result($rst);
$rst = ibase_query($cn, $sql);
while ($row = ibase_fetch_object($rst))
{
echo("ID: " . $row->cod . "<br>\n");
echo("Name: " . $row->name . "<br>\n");
}
ibase_free_result($rst);
?>
</body>
</html>
<?
ibase_close($cn);
?>
PS: I'm using Apache 1.3.27 for Windows, PHP 4.3.1 and Firebird 1.0.2.908
(the latest version of Firebird's 1.0 tree).
--
Edit bug report at http://bugs.php.net/?id=23613&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23613&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23613&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23613&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23613&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23613&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23613&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23613&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23613&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23613&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23613&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23613&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23613&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23613&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23613&r=gnused