LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Change PHP error message. (https://www.linuxquestions.org/questions/programming-9/change-php-error-message-300110/)

agallant 03-10-2005 03:29 PM

Change PHP error message.
 
I have a site that people get emailed registration codes to. When they go to the site there is a box that asks for them to enter there code. If they put in a correct code it pulles there record if they put in no code or mistype there code the get the following error message

You have an error in your SQL syntax near '' at line 1

How do i change the error message? If it could just say some thing like invalid code please use your back button to try agian would be good enoughf.

Thanks,
AG

TheLinuxDuck 03-10-2005 04:21 PM

The issue here is that this error is telling you that the code needs to better-error check the data being given by the user, before the SQL statement is called. It is a fallacy to assume that the user knows what they are doing, even if you think that they may. Firstly, if the user doesn't input anything into the entry field, the SQL call should never happen. Second, is the user entry only supposed to be numbers? Or can it be numbers and letters? More to the point, what is the data type in the table to which the user-entered code refers? If it's only a number, then the code needs to make sure that what they entered was only a number before it is passed the SQL. If it's only supposed to be numbers/letters, the code needs to make sure that it doesn't include any other symbols. You get what I'm saying? Error check the ever loving crap out of their input, and your code will be the better for it.


All times are GMT -5. The time now is 02:52 PM.