You are here: Re: A small problem in running PHP4 under PHP5 - $row[fieldname] « PHP Programming Language « IT news, forums, messages
Re: A small problem in running PHP4 under PHP5 - $row[fieldname]

Posted by Oliver Grδtz on 06/30/07 07:29

xhe schrieb:
> I have just upgraded my php version form php4 to php5. and I met this
> problem, and don't know if you know the solution.
> My site was written in PHP4, and most parts can be running smoothly in
> PHP5, only that in old version, I can use $row[fieldname] to access
> the data in database directly, no need to put double quote around
> fieldname. BUT in PHP5, this is wrong, I got error message "undefined
> constant". I know this is because PHP5 see the fieldname without
> double quote as constant instead of name of field. I know the slowest
> solution is to add double quotes one by one, but this will take a lot
> time.

No, the behaviour hasn't changed. PHP4 also treats the fielname without
quotes as a constant. Undefined constants that a script tries to access
are implicitly/conveniently defined to have their name as content so the
script works as expected. And it still works in PHP5. You just use an
installation with more strict error_reporting. Have a look at
configuring the error reporting settings or (better) change your script
to use strings like in $row['fieldname'].

OLLi


--
"No self-respecting man in Iowa goes anywhere without beer."
[LOST 122]

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация