IF's!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay, I know this is probably a real easy fix, and I could swear I've done
it before, but for some reason it's just not working.

Below is my query, it does a conditional search based on info put in a form
by the user. If I put in a valid letter/name for the last_name that I know
is in my database everything works fine.

BUT, if I put in a character/name for the last_name that does not exist in
my database I get the following error: Call to undefined function
mssql_error() when I should be getting the echo, "No results"

The snipet of my code that is throwing the error is:
if (!empty($tot_result)) {
$total_results = mssql_num_rows($tot_result) or die(mssql_error());
}

Should I not use (!empty()) when checking to see if a query did not return
any results?

MY CODE:
<?php
// Figure out the total number of results in DB:
$sql_total= "SELECT * FROM payment_request WHERE payment_request.status_code
= 'P'";
 if ($customer_last != "") {
 $sql_total.=" AND last_name LIKE '$customer_last%'";
 if ($customer_first != "") {
 $sql_total.=" AND first_name LIKE '$customer_first%'";
   }
  }
$tot_result = mssql_query($sql_total) or die(mssql_error());
if (empty($tot_result)) {
 echo "No results";
 }
if (!empty($tot_result)) {
$total_results = mssql_num_rows($tot_result) or die(mssql_error());
}
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
//echo "Results per page: ".$max_results."\n <br />";
//echo "Total results: ".$total_results."\n <br />";
//echo "Total number of pages needed: ".$total_pages."\n <br />";
?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux