Re: mysqli_query() returns NULL?

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

 




Alex <niksoft@xxxxxxxxx> wrote:

>If you were to use the proper object form of it, you'd spot the
>mistake, as it will tell you that you are trying to perform an action
>on a non-object. 
>
>It might be a bug, or the developers might not have cared figuring that
>if you threw it in an if(!...) it would validate as false anyways. But
>it.might be a bug or an oversight. It might actually be falling through
>some ifs and returning the result that was instantiated as null, I
>dunno...
>
>Sent from my Verizon Wireless 4GLTE smartphone
>
>----- Reply message -----
>From: "James Colannino" <james@xxxxxxxxxxxxx>
>To: <php-general@xxxxxxxxxxxxx>
>Subject:  mysqli_query() returns NULL?
>Date: Fri, Jun 17, 2011 4:40 pm
>
>
>Hey everyone,
>
>After reading the documentation for mysqli_query(), I was lead to 
>believe that on any error it would return false.  However, through a 
>stupid mistake, I discovered that when I specify an invalid value for 
>the database link identifier (in my case, I accidentally passed an 
>integer), instead of false I get a return value of NULL.  Does anyone 
>know why?
>
>Thanks!
>
>James
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

You'll only get an error if there was an error with the query. A query that has no result is still a valid query, so won't return an error. It's quite common to check the value of mysql_num_rows() before trying to use the results of the query.

Ashley Sheridan
http://www.ashleysheridan.co.uk
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[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