Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old May 28th, 2005, 04:32 PM
Rupert Rupert is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 Rupert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
lack of Error checking in tutorial code

Hi first let me say thanks for your tutorials.

I have found the PHP tutorial

http://codewalkers.com/tutorials/12/4.html

basicly very useful.

But the code in this tutorial works fine as long as your check one of the 3 checkboxes on the form.

But if you don't check any checkbox it generates the following error:

Warning: Invalid argument supplied for foreach() in ...

Unfortunatly at the moment I don't have enough PHP skill to work out how to write the error checking required to prevent this.

Can you add this to the tutorial?

Regards,

Rupert Russell
r.russell at ballarat.edu.au



Reply With Quote
  #2  
Old May 28th, 2005, 06:40 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,937 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 1 h 57 m 37 sec
Reputation Power: 3
Orkut
RE: lack of Error checking in tutorial code

I believe that the idea of the tutorial is to demonstrate checkboxes etc and not to bulk up the example with error handling code. The idea of the tutorials is to demonstrate how to do something and the idea is that the code in most of them can be expanded and worked upon (eg by adding error handling etc).

However it should be quite easy to add basic error handling to this example something like this should do the trick.
php Code:
Original - php Code
  1.  
  2. if(count($_POST['mycheckbox']) < 1){
  3. die("ERROR: You must check at least one checkbox!");
  4. }else{
  5. foreach($_POST['mycheckbox'] as $value) {
  6.     echo "<BR>You clicked checkbox number ".$value."n";
  7. }
  8. }

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > lack of Error checking in tutorial code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway