Re: MySQL query results
| From: | Rasmus Lerdorf | Date: | Sat, 23 Mar 2002 00:07:47 +0000 |
| Subject: | Re: MySQL query results | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-89785@lists.php.net to get a copy of this message | ||
http://www.php.net/manual/en/function.mysql-affected-rows.php
On Fri, 22 Mar 2002, Ashley M. Kirchner wrote:
>
> After a bit of research:
>
> ----------
> Rick Emery wrote:
>
> > $result = mysql_query(.....)'
> > mysql_num_rows($result)
>
> Hrm, this is resulting in:
>
> <b>Warning</b>: Supplied argument is not a valid MySQL result resource in
> <b>./index.php</b> on line <b>16</b><br>
> Rows
> ----------
>
>
> Rightfully so. mysql_query() will only return true/false for UPDATEs
> indicating failure/success. And, it's perfectly normal for it to be TRUE even
> if absolutely nothing was changed in the DB - the query was successful. And
> mysql_num_rows($result) fails because $result=1 (assuming the query was valid).
>
> So, I need a different way to approach this so I can get some type of
> indication that something did change in the DB, or whether no records were
> found in the first place.
>
> I'd hate to have to do this in two steps, first query the DB with a SELECT
> statement, and if something was found, then do an UPDATE.
>
> Anyone have any other ideas?
>
> --
> W | I haven't lost my mind; it's backed up on tape somewhere.
> +--------------------------------------------------------------------
> Ashley M. Kirchner <mailto:ashley@pcraft.com> .
> 303.442.6410 x130
> IT Director / SysAdmin / WebSmith . 800.441.3873 x130
> Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6
> http://www.pcraft.com ..... . . . Boulder, CO
> 80303, U.S.A.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>