RE: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1
| From: | Scott Brown | Date: | Tue, 13 Feb 2001 04:54:08 +0000 |
| Subject: | RE: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39341@lists.php.net to get a copy of this message | ||
> Forgot to ask - does referencing an array with double quotes
> around the key work for arrays not associated with a MySQL
> result? I doubt it's specific to MySQL result arrays, but
> it doesn't hurt to check. Make a small array and test.
I grabbed an example of of php.net dealing with just arrays and it works ...
Here's what I'm seeing - THIS WORKS:
<HTML>
<HEAD>
<TITLE>mysqltest</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?
require($DOCUMENT_ROOT . "/subs/sub.php");
openDSN();
echo "<table>\n";
$rslt = mysql_query("select * from pricing");
while ( $row = mysql_fetch_array($rslt) )
{
echo "<TR>\n";
echo "<TD>$row[ID]</tD>";
echo "<TD>$row[ProdCode]</tD>";
echo "<TD>$row[Price_effdate]</tD>";
echo "<TD>$row[ProdSetup]</tD>";
echo "<TD>$row[ProdMonthly]</tD>";
echo "<TD>$row[5]</tD>";
echo "</TR>\n";
}
echo "</table>\n";
?>
</BODY>
</HTML>
But put any one of these $row[...] with quotes around their fieldnames and I
get:
Parse error: parse error, expecting
T_STRING' or T_VARIABLE' or
`T_NUM_STRING' in /home/testnexus/public_html/test.php on line 16
(when line 16 =
echo "<TD>$row["ID"]</tD>";
)