Forums

Database error handling

Lesanjo 23 Feb, 2013
Hello everyone,

Im using Chronoform v4 rc 3.5.2.5 on Joomla 3.0.3 and so far, so good.

However, Im finding the response of the form to database queries returning NULL a little too extreme; my form is replaced with an error page. Granted that once in a while queries will return null results, Im worried of this rendering my site unusable.

Is there a way I can prevent the error screen from showing?

Thanks
GreyHead 23 Feb, 2013
Hi Lesanjo,

What is the error that you get?

Bob
Lesanjo 23 Feb, 2013
If you look at code.jpg, you'll see the highlighted code. when this code is included in the query, the error in error.jpg is seen.

It doesnt make sense because there isnt any sql syntax error, only a null result.
GreyHead 23 Feb, 2013
Hi Lesanjo,

You need quotes round the email address string:
$query = "SELECT * FROM #__lesvoter WHERE email = '".$form->data['cfu_email']."';

or better:
$query = "SELECT * FROM `#__lesvoter` WHERE `email` = '{$form->data['cfu_email']}';

Bob
Lesanjo 23 Feb, 2013
works...can't believe I ignored this basic rule. However , I'm lifting the code from a Joomla 2.5.7 site and it appears this syntax requirement is less strict.

Thanks, you are a life saver:))
GreyHead 23 Feb, 2013
Hi lesanjo,

An integer value like 999 will be OK without the quotes but a string always needs them.

Bob
This topic is locked and no more replies can be posted.