You are here: Re: MSSQL_QUERY not returning True « PHP Programming Language « IT news, forums, messages
Re: MSSQL_QUERY not returning True

Posted by C. (http://symcbean.blogspot.com/) on 10/08/07 11:34

On 8 Oct, 04:52, BethH <hartman.b...@gmail.com> wrote:
> According to php.net, mssql_query is supposed to return true when no
> rows are returned. I'm actually getting an empty resource identifier
> instead of true.
>

I've not checked the manual, but I'd be very surprised if that was the
case. Certainly it should return false if the query fails, and a valid
resource if successful. Note that in PHP in a boolean context, a non-
zero value is dynamically retyped to a true boolean and zero to false.

> I'm not sure how I could have messed it up. I tried looking for bool-
> true (=== TRUE), but it didn't catch it. So then I tried any true (==
> TRUE), and it worked. So then I tried looking for a bool (is_bool)
> and it didn't catch it. Finally, I had it just print the result and
> it gives me a resource identifier.
>

Try:

if ( $Result ) {
// query worked, but we don't know how many rows it returned until
we go looking
$count=0;
while ($Row = mssql_fetch_assoc($Result)){
$count++;
[code to make a table with the data]

}
if (!$count) {
print "No rows returned";
}
} else {
// query has failed - but should already have thrown an error
}

Alternatively use the mssql_num_rows() function.

C.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация