note 36270 added to function.mysql-free-result
| From: | lew at mailduct dot com | Date: | Fri, 03 Oct 2003 00:40:46 +0000 |
| Subject: | note 36270 added to function.mysql-free-result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57638@lists.php.net to get a copy of this message | ||
You can only use mysql_free_result with queries that return result sets. Calling mysql_free_result
after a query that does not return a result set will generate an error:
PHP Warning: mysql_free_result(): supplied argument
is not a valid MySQL result resource in /prog/......
Do NOT use this for queries such as INSERT, UPDATE, etc. Only use it for queries that actually
return result data (as opposed to status data - eg: TRUE/FALSE success info).
#### INVALID:
$query = "INSERT INTO music VALUES( '12','hip-hop' );"
$go = mysql_query( $query ) or die( 'INSERT failed' );
// Free result memory, since we don't need it
mysql_free_result( $go );
#### VALID:
$query = "SELECT * FROM music WHERE $album=12";
$go = mysql_query( $query ) or die( 'SELECT failed' );
// Free result memory, since we don't need it
mysql_free_result( $go );
Hope this helps.
----
Manual Page -- http://www.php.net/manual/en/function.mysql-free-result.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36270
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36270&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36270&report=yes