|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-16 11:25 UTC] oliver at samera dot com dot py
If you use the result set of a insert query, you get a warning message.
// connect
// do an insert
$result = mysql_query("insert into table1(col1) values(1)");
// free a result
mysql_free_result($result);
// a warning is generated
Warning: Supplied argument is not a valid MySQL result resource in your_source.php on line line_number
php-mysql-4.0.4pl1-9
mysql-3.23.36-1
RedHat 7.1
'./configure' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--enable-shared' '--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-exec-dir=/usr/bin' '--with-regex=system' '--with-gettext' '--with-gd' '--with-jpeg-dir=/usr' '--with-png' '--with-zlib' '--with-db2' '--with-db3' '--with-gdbm' '--enable-debugger' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp' '--enable-ftp' '--enable-wddx' '--without-mysql' '--without-oracle' '--without-oci8' '--with-xml'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
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); }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 ... }