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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to avoid php default errors or customize them

Status
Not open for further replies.

sbayter

IS-IT--Management
Joined
Nov 14, 2002
Messages
95
Location
CO
Hi,
I have a survey which is composed of around 10 questions. For each question you can answer from 1 to 10 using radio buttons.
I have a javascript script validator with a if statements for each question so if the user does not check any radio in some question it will tell the user to try again.
The problem is that when user does not check any of the questions and javascript pops up the alert then the user is redirected to a balck page with the default php error "Column 'question1' cannot be null"
Is there any way to avoid this php error.
Thanks in advance for ur help,



sbayter
 
I don't know anything about your code to know what part of PHP's myriad subsystems is generating that error, so I can only comment in general.

PHP produces those ugly errors only when your code has produced an error that the code itself has not handled. Deal with the errors in your code so PHP doesn't have to.

You're using HTML as your user interface, so you have ample opportunities to control input. Simply making one of your radio buttons default to selected when your page is loaded would help a lot.


Want the best answers? Ask the best questions: TANSTAAFL!
 
I started handling error inside the page.
When the user does not check any button it says so. however all the answer he/she had done are deleted. In other word, he/she would have to re do all the questions again.
Is there any way to save the answered ones?
Thanks,

sbayter
 
Canonically, there are two ways to do it.

One is to use sessions. As you process each answer, record it in an array in a session variable.

The other is to accumulate the answers in hidden form fields on each successive page.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top