Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP - Joomla variable $A not recognized

Newbie
 
Join Date: Apr 2008
Posts: 3
#1: Apr 16 '08
Working with PHP script and Joomla - When I define a variable in the script (see example 1 below), install the compoment in joomla, select the menu item, nothing happens. The error log says:

PHP Notice: Undefined variable: act in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\joomla\\components\ \com_ectpequipmentlist\\ectpequipmentlist.php on line 37, referer: http://localhost/joomla/index.php

If I hard code a value in the default option of the script (see example 2), install the compoment, select the menu item the data appears correctly.

Example 1: Code that does not work:[php]global $database;
echo 'made it here';

include("class/ectpequipmentlist.php");
$EL = new EquipmentList();
switch( $act )
{
case 'search':
$EL->searchPosition($buildingid, $floor, $pos);
break;
case 'view':
$EL->viewPosition($positionid);
break;
default:
$EL->searchForm();
break;
}[/php]Example 2: Code that does work:[php]global $database;
include("class/ectpequipmentlist.php");
$EL = new EquipmentList();
switch( $act )
{
case 'search':
$EL->searchPosition($buildingid, $floor, $pos);
break;
case 'view':
$EL->viewPosition($positionid);
break;
default:
$EL->viewPosition('200');
break;
}[/php]

ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Apr 16 '08

re: PHP - Joomla variable $A not recognized


It most likely is not an error, but a notice or warning. Just means that you use a variable that has not been declared/initialized. It is always better to do that.

You can ignore this notice or set notices off completely in your PHP script.

Ronald
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,940
#3: Apr 16 '08

re: PHP - Joomla variable $A not recognized


Quote:

Originally Posted by dkas

Using PHP and Joomla - a define a variable run menu in Joomla and the error log says: Undefined variable in php script file. If I hard code a value the menu works correctly.

What missing?

You can add the @ symbol at the begging of the variable, to surpress an error.
Newbie
 
Join Date: Apr 2008
Posts: 3
#4: Apr 16 '08

re: PHP - Joomla variable $A not recognized


Quote:

Originally Posted by ronverdonk

It most likely is not an error, but a notice or warning. Just means that you use a variable that has not been declared/initialized. It is always better to do that.

You can ignore this notice or set notices off completely in your PHP script.

Ronald

I'm a newbie. I added some additional information to my post. Thank you for the reponse. If you could look at the post again that would be great.
Newbie
 
Join Date: Apr 2008
Posts: 3
#5: Apr 16 '08

re: PHP - Joomla variable $A not recognized


Quote:

Originally Posted by markusn00b

You can add the @ symbol at the begging of the variable, to surpress an error.

Thank you for responding. I added some additonal information. I'm a newbie and I cannot get the code to work correctly unless I hard code a value.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#6: Apr 16 '08

re: PHP - Joomla variable $A not recognized


WARNING:
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Reply