[thelist] mysql_affected_rows();

Chris Blessing webguy at mail.rit.edu
Fri Sep 27 15:05:08 CDT 2002


Hey there-

Actually mysql_query() uses the same connection opened by mysql_connect(),
which I presume is somewhere else in your code?

The edit was saying that you must open a connection somehow before
attempting to get the # of affected rows.

Per that documentation note below about it only returning the # of rows
*changed* from their original value, I'd say everything is actually working
properly!

And you weren't gettin lucky, I think PHP may have been converting the
string to an integer rather than integer -> string, since the string only
contained a numeric value.  My bad on that, didn't think of it that way.

Good luck!

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net

> Hey chris,

> hmm, that hasn't worked either - it's still the same
> wrong-way-round result.
>
>
> oh.
> it works fine for all my other queries... must have been lucky...
>
>
> Ah, just found this:
>
> "...it appears that the number of affected rows returned per above in an
> update query will be the number whose values were actually changed. So
> updating a unique record whose value is "somevalue1" to "somevalue1" will
> return zero rows affected. Whereas updating a unique record of
> "somevalue1"
> to "somevalue2" will return '1'."
>
> So it _is_ deciding that as my record hasn't changed, it doesn't count
> as 'updated'?
>
> "[Editor's Note: Review the above documentation carefully!
> mysql_affected_rows
> () works with connection handles returned by mysql_connect() or
> mysql_pconnect
> (), not with result handles returned by mysql_query() or mysql_db_query()"
>
>




More information about the thelist mailing list