| Posted by Lenard Redwood on 06/13/67 11:56 
I have the maximum number of warnings during PHP development. How can Iget rid of these warnings without turning them off in PHP?
 
 Here's the code I have:
 
 <form method="POST" action="eat.php">
 <select name="lunch[  ]" multiple>
 <option value="pork">BBQ Pork Bun</option>
 <option value="chicken">Chicken Bun</option>
 <option value="lotus">Lotus Seed Bun</option>
 <option value="bean">Bean Paste Bun</option>
 <option value="nest">Bird-Nest Bun</option>
 </select>
 <input type="submit" name="submit">
 </form>
 
 Selected buns: <br/>
 <?php
 foreach ($_POST['lunch'] as $choice) {
 print "You want a $choice bun. <br/>";
 }
 ?>
 
 
 And I get: Warning: Invalid argument supplied for foreach() in
 C:\lighttpd\htdocs\index.php on line 17
 
 Is there a way to give the 'lunch' variable a default value if
 undefined?
 Thank you.
  Navigation: [Reply to this message] |