Thanks!
I think I saw mssql_error() somewhere on a forum a long time ago so I just
inherently started using it. Thanks for pointing that out.
Jim, yes you are right...that was just a portion of my code. The entire
page in which that section resides is over 900 lines and I didn't want
everyone to wade through the trash to get to the issue.
Thanks for the help,
Dan
On 9/26/07, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
> On 9/26/07, Dan Shirah <[EMAIL PROTECTED]> wrote:
> > 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 />";
> > ?>
> >
>
> Dan,
>
> Your syntax is correct, but mssql_error() doesn't exist in PHP to
> my knowledge. Try replacing that with `mssql_get_last_message();`
> (sans quotes, of course) and see if that fixes the problem.
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>
> Give a man a fish, he'll eat for a day. Then you'll find out he was
> allergic and is hospitalized. See? No good deed goes unpunished....
>