Error message when using variables

tnijman 29 Dec, 2008
I don't want users to see all the data in the table so is there a way to show them an error message when the variable is enterered wrong in the form. Now when you haven't filled in a correct 'isbn' (&isbn=...) it shows a database error. How can I create a custom error message?
This is my code.

WHERE isbn = <?php echo JRequest::getVar('isbn'); ?>


<div>
<strong>Naam:</strong> {naam}<br>
<strong>Beschrijving:</strong> {beschrijving}<br>
<strong>ISBN:</strong> {isbn}<br>
<strong>Uitgever:</strong> {uitgever}<br>
<strong>Waarde:</strong> {huidigeprijs}<br>
</div>


Thanks!
GreyHead 29 Dec, 2008
Hi tnijman,

This might work:
<?php
if ( $db->getNumRows() == 0) {
   echo "No results were found";
} else {
?>
<div>
<strong>Naam:</strong> {naam}<br>
<strong>Beschrijving:</strong> {beschrijving}<br>
<strong>ISBN:</strong> {isbn}<br>
<strong>Uitgever:</strong> {uitgever}<br>
<strong>Waarde:</strong> {huidigeprijs}<br>
</div>
<?php
}
?>
These probably don't all go in the same place in ChronoConnectivity but the principle should work.

Bob
tnijman 30 Dec, 2008
I still get the same message this is the output:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 SQL=SELECT count(*) FROM jos_chronoforms_schoolboeken WHERE isbn =


The message comes above the header of the component.
Thanks for the help though!
tnijman 30 Dec, 2008
When I fill in the 'isbn' correctly: the site disappears and only the header is shown without styling..
GreyHead 30 Dec, 2008
Hi tnijman,

For development I suggest that you turn Erro Reporting for your site up to Maximum. The blank page *probably* results from a PHP Error that isn't being shown.

I'm not sure where the '' in the SQL comes from; it could be a blank ISBN. If so, you probably need to check for a blank entry before making the database call. I've no idea how you do that in ChronoConnectivity? Shouldn't ther eonly be valid entries on the display page?

Otherwise it could be misquoted SQL syntax - can you show us all the code here?

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