?
Solved

PHP 4.1.2 to 4.3.1 conversion problem with associative arrays

Posted on 2003-03-24
4
Medium Priority
?
229 Views
Last Modified: 2006-11-17
On one of my machines php 4.1.2, the following line works..

$installedModules[1] = array(module=>"Marketing", phpfile=>"cmps_marketing.php");

On another of my machines, 4.3.1, it doesn't work returning the error:

Notice: Use of undefined constant module - assumed 'module' in ..\index.php on line 44
Notice: Use of undefined constant phpfile - assumed 'phpfile' in ..\index.php on line 44


I have never had to do any typing on an associative array before.. what is the "correct" way to do this?
0
Comment
Question by:Palamedes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
VGR earned 100 total points
ID: 8197403
of course 8-)

your 'module' and 'phpfile' have the syntax of PHP CONSTANTS (ie, no $ before the name -> variable, no quotes around -> string, and not a numerical value. Thus PHP asusmes it must be constants (define()) and you've not defined them.

This is 100% incorrect

If "it works" on an other installation, it must be because your reporting level did not include NOTICEs ;-)
(check php.ini for ERROR )

Change this into :
installedModules[1] = array('module'=>"Marketing", 'phpfile'=>"cmps_marketing.php");
0
 
LVL 4

Author Comment

by:Palamedes
ID: 8197508
That did the trick..

Thanks bud..  I even have a book that doesn't show putting single quotes around it..

I understand of course now why they are necessary.. It seems like typing wasn't as strong several versions ago..

Cheers.
0
 
LVL 15

Expert Comment

by:VGR
ID: 8197598
just by curiosity : are you Greek ?
0
 
LVL 4

Author Comment

by:Palamedes
ID: 8199067
No.. but Palamedes was.. =)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question