RE: [PHP4BETA] mysql_affected_rows doesn't like it's argument.
| From: | August Zajonc | Date: | Mon, 27 Mar 2000 09:14:09 +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-12665@lists.php.net to get a copy of this message | ||
Ouch, my appologies to the list. Looking back over some older working code I
see $db instead of $result as well.
August
> -----Original Message-----
> From: Paul DuBois [mailto:paul@snake.net]
> Sent: Sunday, March 26, 2000 1:48 PM
> To: August Zajonc; PHP4-list
> Subject: Re: [PHP4BETA] mysql_affected_rows doesn't like it's argument.
>
>
> 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.