Bug #16295 Updated: # is not a valid resource

From: Date: Wed, 27 Mar 2002 11:16:05 +0000
Subject: Bug #16295 Updated: # is not a valid resource
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-3469@lists.php.net to get a copy of this message
ID: 16295 Updated by: georg@php.net Reported By: joyeux@1984.cz Status: Bogus Bug Type: MySQL related Operating System: MDK 8.2 PHP Version: 4.1.2 New Comment: Don't mix mysql_unbuffered_query and mysql_query. mysql_unbuffered_query is for fetching rows in SELECT, SHOW or DESCRIBE statements without buffering it. Use mysql_query ("DELETE ... instead. Previous Comments: ------------------------------------------------------------------------ [2002-03-27 06:15:58] georg@php.net Don't use mysql_unbuffered_query and mysql_query mixed. mysql_unbuffered_query is for fetching rows in SELECT, SHOW or DESCRIBE statements without buffering it. Use mysql_query ("DELETE ... instead. ------------------------------------------------------------------------ [2002-03-27 05:28:54] joyeux@1984.cz This SOMETIMES produces an error "3 is not a valid mysql resource on line 2" (or other error numbers) First fetch_array is usually good. It looks like php forget a resource link when calling other query (line 3). 1| $sql=mysql_query("SELECT id FROM tbl"); 2| while($row = mysql_fetch_array($sql, MYSQL_ASSOC)) { 3| mysql_unbuffered_query("DELETE FROM tbl2 WHERE id=".$row["id"]); 5| } When I first fetch all data to an array and then use them by the same way, it works. 1| $ARR=array(); 2| $sql=mysql_query("SELECT id FROM tbl"); 3| while($row=mysql_fetch_array($sql, MYSQL_ASSOC)) $ARR[]=$row; 4| foreach($ARR as $row) mysql_unbuffered_query("DELETE FROM tbl2 WHERE id=".$row["id"]); I can't find where is the problem. I try to put some sleep() after queries but nothing happens. ------------------------------------------------------------------------ [2002-03-26 18:38:18] joyeux@1984.cz This SOMETIMES produces the error "3 is not a valid mysql resource on line 2" (or other numbers) First fetch_array is usually good. It looks like php forgot a resource link when calling other query. 1| $sql=mysql_query("SELECT id FROM tbl"); 2| while($row = mysql_fetch_array($sql, MYSQL_ASSOC)) { 3| mysql_unbuffered_query("DELETE FROM tbl2 WHERE 4| id=".$row["id"]); 5| } When I use an array to store data from tbl1 instead direct fetching, it works. 1| $ARR=array(); 2| $sql=mysql_query("SELECT id FROM tbl"); 3| while($row=mysql_fetch_array($sql, MYSQL_ASSOC)) $ARR[]=$row; 4| foreach($ARR as $row) mysql_unbuffered_query("DELETE FROM tbl2 WHERE id=".$row["id"]); I can't find where is the problem. I try to put some sleep() after mysql_query but it's the same. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16295&edit=1

« previous php.bugs (#3469) next »