473,474 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A small problem in running PHP4 under PHP5 - $row[fieldname]

xhe
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.
So are there any solution to change configuration in php.ini and let
PHP5 accept this kind of usage just like that in PHP4?
Thanks.

Jun 29 '07 #1
3 3277
On Jun 29, 1:04 pm, xhe <hexuf...@gmail.comwrote:
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.
So are there any solution to change configuration in php.ini and let
PHP5 accept this kind of usage just like that in PHP4?
Thanks.
It didn't technically work in PHP4, either. You just didn't have
error reporting turned on so you never really noticed. While you
might see it as a hassle to add the quotes back in it is the correct
way to fix it. The way to "fix" it in PHP5 is to disable error
reporting -- although you haven't really fixed anything that way. I
strongly suggest you actually correct the code.

Jun 29 '07 #2

"xhe" <he******@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>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.
So are there any solution to change configuration in php.ini and let
PHP5 accept this kind of usage just like that in PHP4?
Thanks.
Hi xhe,

I would not recommend changing the settings.
Why not fix the problem now? You will only run into it again later.

Find a regular expression that replaces the [ ] with [" "]
or do search and replace in a decent text editor.
Its not that hard to do.

Richard.
Jun 29 '07 #3
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]
Jun 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Craig | last post by:
How do you set the current row of a dataset? I want to bind a control to a field from the 5th row in a dataset. I fill the dataset, then I want to set the row to the 5th row and then do the...
3
by: Jeremy | last post by:
The example for updating an non-strong typed dataset in the resource kit shows: dsNorthwind.Tables("ProductsDS").Rows(lstResults.SelectedIndex)("ProductName ") = ProductName & " - Updated" ...
2
by: Billy | last post by:
I need some help with solving my problem. I'm writing general procedure to find a values in any table. My idea is to pass to that procedure: TableName and ArrayList with parametere. Arraylist...
2
by: Trip | last post by:
Hello all, Is there anyway to store an array to MS Access 2002 without parsing the entire array row-by-row. For example, Oracle allows you to store BLOBs (binary large objects). I would like...
2
by: alan | last post by:
Hi, Not sure if i'm phrasing this correctly but is it possible to format my datagrid with the colums as row labels/headers ? I've got one record with 12 fields and rather than displaying this...
3
by: Elmo Watson | last post by:
I previously had a project working, in which the Gridview was populated by a DataSet - then, with a DropDownlist in one of the columns, using the OnrowDataBound event, to populate the DDL with the...
3
by: Phil Stanton | last post by:
I have a number of queries which use code for the output of 1 or more fields. For example Address:GetAddress(AddressID, True, 60) Address ID Points to an Address in a table - Address Line1, Line...
1
by: BrianMiller | last post by:
I have searched for an answer but have failed to come up with anything that seems to work. I am trying to set up an Access 2003 database for home accounts. I want to create a running sum (a...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.