Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Aruments

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello All:

Can someone gives me a poniter on why I am getting:
Warning: Invalid argument supplied for foreach() in emp_array.php on line 20

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  
  <title> Employee Array </title>
  
 </head>
 <body>

 <form action="emp_array.php" method="post">

$employees = array("Ann Jones", "John Smith", "Barny Ruble", "Fred Flintstone", "Pebbles Flintstone", "Betty Rubble");

 </form>

<?php 

foreach ( $employees as $employee ) {
  print $employee . "<br />";
}

?>
</body>
</html>

Thanks for your patient and help
 
Invalued Arguments for the title.
 
Because since your employees array is not between PHP tags <?PHP ?> its just text, so to PHP $employees is not a valid array since its technically no defined.

You should be getting an "Notice: Undefined variable: employees in ..." notice as well for that same reason. Unless your PHP installation is set to not show Notices.

Code:
 <form action="emp_array.php" method="post">
[COLOR=white red]<?PHP[/color]
$employees = array("Ann Jones", "John Smith", "Barny Ruble", "Fred Flintstone", "Pebbles Flintstone", "Betty Rubble");
[COLOR=white red]?>[/color]
 </form>



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top