Re: 3.0.12: mysql_store_result in php3_mysql_query
| From: | Zeev Suraski | Date: | Fri, 03 Sep 1999 00:23:13 +0000 |
| Subject: | Re: 3.0.12: mysql_store_result in php3_mysql_query | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-10478@lists.php.net to get a copy of this message | ||
At 23:59 02/09/99 , Rasmus Lerdorf wrote:
Hrm.. That does look a bit odd. This change was made Friday, October 24, 1997 by Zeev. I am sure he remembers why he made the change! ;) See http://cvs.php.net/cvsweb.cgi/functions/mysql.c and go down to the 1.41 change. Zeev's comment just says, "Fixed a free() that should have been efree() on a failed mysql_connect()" which doesn't really seem to relate to this particular change. On Thu, 2 Sep 1999, David Sklar wrote: I have a page that does: $r = mysql_query('select ping from ping'); if ($r) {Actually no, mysql_store_result() returns NULL in many cases. You may call them errors, but from our point of view, they aren't. Basically, two types of things may cause mysql_store_result() to return NULL. First, and the very unlikely case, is the case of an actual error (which is pretty much limited to an our-of-memory error). If that happens, you're screwed anyway. The second case, and the very common one, is when there's no result to store, because the query was an data-manipulation query (insert, update, delete, etc) and not a select. In these cases, mysql_store_result() returns NULL, and nonetheless, mysql_query() (PHP's) must return true. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.ilif ($ob = mysql_fetch_object($r)) { echo $ob->ping."\n"; } else { echo "Can't get ob\n"; }} else { echo "Can't do query\n"; } Very infrequently, when accessing this page, I get a "PHP 3 Warning: 1 is not a MySQL result index" at the line with mysql_fetch_object(). So mysql_query is returning 1 (or TRUE that gets evaluated to 1?) but it's still not really a result handle. Could the following code in php3_mysql_query() be responsible: ?if ((mysql_result=mysql_store_result(mysql))==NULL) { /*php3_error(E_WARNING,"Unable to save MySQL query result"); RETURN_FALSE; */ RETURN_TRUE; }Why is it returning true if there was an error? mysql_store_result() returns NULL if an error occurs.