Re: [PHP] Class Function Problem

2002-12-10 Thread Rodney Green
Where is the array $tools defined? The count() function returns the
number of elements in a variable (in this case an array).
It is seeing that there are 0 elements in the $tools array and
therefore your script is trying to divide 100 by 0 which
will spit out a warning every time. Should $tools be $toolsneeded
instead?





- Original Message -
From: "Sean Mayhew" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 10, 2002 3:59 PM
Subject: Re: [PHP] Class Function Problem


: while(list($name,$url) = each($tools))
:
:
: >From: "Rodney Green" <[EMAIL PROTECTED]>
: >To: <[EMAIL PROTECTED]>
: >CC: <[EMAIL PROTECTED]>
: >Subject: [PHP] Class Function Problem
: >Date: Tue, 10 Dec 2002 15:58:09 -0500
: >
: >What is on line 251?
: >
: > >Warning: Variable passed to each() is not an array or object in
: > >/home/www/website/admin/include/adminclass.php on line 251
: >
: >
: >--
: >PHP General Mailing List (http://www.php.net/)
: >To unsubscribe, visit: http://www.php.net/unsub.php
:
:
: _
: MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
: http://join.msn.com/?page=features/virus
:
:


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Class Function Problem

2002-12-10 Thread Rodney Green
What is on line 251?

>Warning: Variable passed to each() is not an array or object in
>/home/www/website/admin/include/adminclass.php on line 251


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Class Function Problem

2002-12-10 Thread Sean Mayhew
I have an admin panel that each section contains a set of tools so on each
page I can set $toolsneeded = "admin" or $toolsneeded = "employees"; etc.



I keep recieving this error:
Warning: Division by zero in /home/www/website/admin/include/adminclass.php
on line 250

Warning: Variable passed to each() is not an array or object in
/home/www/website/admin/include/adminclass.php on line 251

This is line 250:  $height = 100/count($tools);


Here is the page that uses the class.
SetContent($redux);

$toolsneeded = "admin";
$adminroot->SetTools($toolsneeded);

$adminroot->Display($employeeid,$password,$title);
?>




Here is my class file with some of the functions removed for brevity. I have
real problems understanding $this-> so you may find that Im using it in the
wrong place or not using it where I should be.

 "orders_root.php",
 "products" => "products_root.php"
 );

##
##SET FUNCTIONS
##
function SetContent($newContent)
 {
 $this->content = $newContent;
 }
function SetTools($newTools)
 {
 $this->toolsneeded = $newTools;
 }

##
##DISPLAY FUNCTION
##
function Display($employeeid,$password,$title)
 {
 session_start();
 session_register("employeeid");
 $count = $this -> VerifyLogin($employeeid,$password);
 switch($count)
  {
  case "1":
   $this -> DisplayHeader($title,$employeeid);
   echo "";
   $this -> DisplayMenu($this->buttons);
   echo "";
   $this -> DisplayContent($this->tools,$this->content);
   echo "";
   $this -> DisplayFooter();
   break;

  default:
   $title = "Please Try Again";
   $employeeid = "";
   $this -> DisplayHeader($title,$employeeid);
   echo "";
   echo "Your username and password combination is incorrect. Please try
again.";
   $this -> DisplayLogInForm();
   echo "";
   $this -> DisplayFooter();
   break;
  }
 }


##
##DISPLAY TOOLS FUNCTION
##
function DisplayTools($tools)
 {
 echo "";
  echo "";
   echo"";
echo"";
###
###Line 250
###
$height = 100/count($tools);
###
###

while(list($name,$url) = each($tools))
{
$this ->ToolsLayout($height,$name,$url);
}
echo "";
   echo "";
  echo "";
 echo "";
 }

##
##TOOLS LAYOUT FUNCTION
##
function ToolsLayout($height,$name,$url)
 {
 echo "";
 echo "[ $name ]";
 }


function ToolSelected($toolsneeded)
 {
 switch($toolsneeded)
  {
  case "admin":
   DisplayTools($toolsadmin);
   break;
  case "orders":
   echo "Order Tools";
   break;
  default:
   echo "Your Tools do not work";
  }
 }


##
##DISPLAY CONTENT FUNCTION
##
function DisplayContent($toolsneeded,$content)
 {
 ?>
 
 
 
  
   
  
   
  
   
  



  


 DisplayTools($toolsneeded);
 ?>



   
   
   
  
 


  
 
 

 
 
  
 
 
 admin
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 a and i balancing administration
  


  
  


  
 http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php