Reply to How to get rid of warnings?

Your name:

Reply:


Posted by Lenard Redwood on 10/18/67 11:56

I have the maximum number of warnings during PHP development. How can I
get 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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация