RE: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

From: Date: Tue, 13 Feb 2001 12:39:38 +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-39402@lists.php.net to get a copy of this message
oh hell. Do I ever feel stupid now. That explains that test script perfectly.... now I just have to figure out whats wrong with the rest of my site.... Obviously, too much "What-the-f..." and not enough "lets look at this logically" occured. Sorry about that. I'll crawl back under my rock now. > -----Original Message----- > From: Steve Werby [mailto:steve@247computing.com] > Sent: Tuesday, February 13, 2001 12:26 AM > To: scott-brown@home.com; php-general@lists.php.net > Subject: Re: [PHP] mysql_fetch_array and row referencing > under 4.0.4pl1 > > > "Scott Brown" <scott-brown@home.com> wrote: > > I grabbed an example of of php.net dealing with just arrays > and it works > ... > > > > Here's what I'm seeing - THIS WORKS: > > <snip> > > while ( $row = mysql_fetch_array($rslt) ) > > { > > echo "<TR>\n"; > > echo "<TD>$row[ID]</tD>"; > </snip> > > > 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>"; > > The double quotes enclose the contents of the echo statement, > but PHP chokes > because you have double quotes inside the echo statement. If > the exact line > above worked under PHP3.x I'm surprised. Solutions include: > > escaping the double quotes > echo "<TD>$row[\"ID\"]</TD>"; > > using no quotes or single quotes: > echo "<TD>$row['ID']</TD>"; > echo "<TD>$row[ID]</TD>"; > > breaking apart the echo statement: > echo "<TD>" . $row["ID"] . "</TD>"; > > I don't think there's any way around this. If you got it to work > differently in PHP3 I'd like to know how. If for some reason > you have a ton > of code you have to change now, you can write a PHP script which uses > regular expressions to find the double quotes to replace, > write out the new > files and cycle through all your files. It really wouldn't > be that hard, > but I still suspect that the double quotes would have been a > problem in PHP3 > too. > > -- > Steve Werby > COO > 24-7 Computer Services, LLC > Tel: 804.817.2470 > http://www.247computing.com/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.general (#39402) next »