Re: [PHP4BETA] mysql_affected_rows doesn't like it's argument.
| From: | Paul DuBois | Date: | Sun, 26 Mar 2000 21:47:44 +0000 |
| Subject: | Re: [PHP4BETA] mysql_affected_rows doesn't like it's argument. | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12653@lists.php.net to get a copy of this message | ||
At 12:38 PM -0800 2000-03-26, August Zajonc wrote:
mysql_affected_rows has some strange behavior. Here's a simplified sample script: $sql = "INSERT INTO Reviews Values (NULL, '0', NOW(), '5', '5', '5', '1', '4', 'gbg', 'fg', 'sdfg');"; $db = mysql_pconnect($db, $us, $pw); mysql_select_db($dbname, $db); $result = mysql_query($sql, $db); echo $result; echo mysql_affected_rows($result); This kicks back the error that $result is not a valid MySQL-Link resource. However, changing the last line to read mysql_affected_rows() works wonderfully. What's strange is that echo $result always returns one. I am assuming that the nature of the query determines whether a link resource is returned or not. Perhaps this has changed recently?You'd be better off reading the manual than making assumptions like that. mysql_affected_rows() takes a link identifier, not a result set identifier. ($db, not $result in your case) If you don't pass an argument, it uses the most recently opened connection. You might be thinking of mysql_num_rows(), which does take a result set identifier. But that function isn't useful with INSERT. -- Paul DuBois, paul@snake.net