Forums

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
This topic is locked and no more replies can be posted.