ID: 14086
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: MySQL related
Operating System: Linux 2.4
PHP Version: 4.0.4pl1
New Comment:

Sorry about the confusion,
as the manual says, only if you use a SELECT statement you can free the result using 
mysql_free_result().

My fault.

This really is a bogus bug report. :-)

Thanks for the is_resourece() tip.

Oliver


Previous Comments:
------------------------------------------------------------------------

[2001-11-16 13:44:17] [EMAIL PROTECTED]

please *read* the manual page or at least the snippet from the previous message

mysql_query() will only return a result set on SELECT statements 

in any other case it will just return true or false which do not need to be freed

if you realy want to be sure you can do something like

$res = mysql_query(...);
if($res) {
  if(is_resourece($res)) {
    ... process result set ...
    mysql_free_result($res);
  } else {
    ... just be happy that your statement succeded ..
  }
} else {
  ... error handling ...
}




------------------------------------------------------------------------

[2001-11-16 13:34:16] [EMAIL PROTECTED]

But, can I free a result set that returned mysql_query in mysql_result_free?

Does this code works? :
// here I'm successfully conected using mysql_pconnect();
$result = mysql_query("insert into table1(col1) values(1)");
if($result) {
  // here I get a warning only if I used a insert statment
  mysql_free_result($result);
}



------------------------------------------------------------------------

[2001-11-16 13:11:03] [EMAIL PROTECTED]

>From the manual: (http://uk.php.net/manual/en/function.mysql-query.php):

 mysql_query() returns TRUE (non-zero) or FALSE  to indicate whether or not the query 
succeeded. A return value of TRUE means that the query was legal and could be executed 
by the server. It does not indicate anything about the number of rows affected or 
returned. It is perfectly possible for a query to succeed but affect no rows or return 
no rows.

<snip>

 For SELECT statements, mysql_query() returns a new result identifier that you can 
pass to mysql_result(). When you are done with the result set, you can free the 
resources associated with it by calling mysql_free_result().

Not a bug, but intended behavior >> bogus

------------------------------------------------------------------------

[2001-11-16 11:30:05] [EMAIL PROTECTED]

Tested in RedHat 7.1 with official updates.

------------------------------------------------------------------------

[2001-11-16 11:29:01] [EMAIL PROTECTED]

Summary changed

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/?id=14086


Edit this bug report at http://bugs.php.net/?id=14086&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to