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

Posted by ZeldorBlat on 10/08/07 17:23

On Oct 7, 11:52 pm, 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.
>
> The table is empty, there are no rows in it at all, so mssql_query
> should always return true, but it isn't. Am I missing something?
> Here's my code:
>
> $StrQuery = "SELECT * FROM BookMarks WHERE UserName='" . $ID . "'";
> $Result = mssql_query($StrQuery);
>
> 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.
>
> It keeps trucking through as if it had actually found something. But
> when I do this:
>
> while ($Row = mssql_fetch_assoc($Result)){
> [code to make a table with the data]
>
> };
>
> nothing happens, because, of course, there are no actual rows, only
> imaginary ones.
>
> I've changed my code to check if the array is false before starting
> the while loop, but that seems like a weird way to go just to see if
> there's any data to work with.
>
> Any Suggestions?

You're getting confused on the definition of "when no rows are
returned." They're talking about a query that doesn't actually return
rows, like insert, update, or delete. A query that returns a result
(like select) will always return a resource identifier, regardless of
how many rows are in the result.

 

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

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