Re: odbc_num_rows always returnes -1
| From: | Jeff Bluemel | Date: | Sun, 20 Oct 2002 19:05:21 +0000 |
| Subject: | Re: odbc_num_rows always returnes -1 | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120682@lists.php.net to get a copy of this message | ||
I finally found some other sources on this, and it appears the negative one
is suppose to be returned when there is an error. however, I used
odbc_result_all to print the result set in a table (automatically). well it
pulls a query ok.
the only way I could fin to test this was to use if(odbc_result_all($sql)),
however, it prints this info in a table which I really don't want it to do.
I believe my only method around this (which won't be an issue for me because
I figured out how to use native odbc driver even for connectivity on another
server) would have been to set the text the same color as the back ground so
the output would have been invisible.
"John W. Holmes" <holmes072000@charter.net> wrote in message
news:000701c277a1$83b0fe90$7c02a8c0@coconut...
> > I've got the following code, and regardless if it finds something or
> not
> > odbc_num_rows returns -1 as the value? curious what I should I use to
> > test
> > whether or not something was found? (the database I am connecting to
> is
> > Informix running on a different server)
> >
> > $sql = odbc_exec($$ntslink,"SELECT lot_card_num_k AS pin,
> current_balance
> > AS
> > balance, first_use_date AS first, lot_num_f AS batch, status_flag AS
> > status,
> > zombie_date AS expired, sequence_number AS serial, zombie_method AS
> reason
> > FROM lot_card WHERE lot_card_num_k = '$pin';") or
> > die("Invalid ODBCQuery");
> > $numrows = odbc_num_rows($sql) if ($numrows <= 0 )
>
> Maybe something like this?
>
> if($row = odbc_fetch_array($sql))
> {
> do{
> //process rows
> }while($row = odbc_fetch_array($sql));
> }
> else
> {
> echo "no rows returned";
> }
>
> ---John Holmes...
>
>