Re: [PHP] mysql_affected_rows() function

From: Michal Oskera (osky_at_volny.cz)
Date: 01/06/04


To: php-general@lists.php.net
Date: Tue, 6 Jan 2004 22:36:19 +0100

Hello,
I use PHP v. 4.3.3 and MySQL v 4.1.0a and
I have the same experience as Tyler. Also when performing INSERT and UPDATE
commands.
And I also don't know why.

Mike

"Cpt John W. Holmes" <holmes072000@charter.net> píse v diskusním príspevku
news:018901c3d49a$18024580$a629089b@tbhhccdr...
> From: "Tyler Longren" <tyler@jdhost.com>
>
> > I don't think mysql_affected_rows() is working like it should for me.
> > In the manual for mysql_affected_rows() it has this (Example 1):
> >
> > /* this should return the correct numbers of deleted records */
> > mysql_query("DELETE FROM mytable WHERE id < 10");
> > printf("Records deleted: %d\n", mysql_affected_rows());
> >
> > However, when I do this:
> > $delete_assignment = mysql_query("DELETE FROM consultingprojectassign
> > WHERE workerid='$assigned[$i]'");
> > printf("Records deleted: %d\n", mysql_affected_rows());
> >
> > It always says "Records deleted: 0". Even though the record was,
> > indeed, deleted. I have an if statement also that says if
> > mysql_affected_rows() < "1", then print an error message. Well, since
> > it always returns 0, no matter what, the error is always shown, even
> > when the record is deleted.
>
> I can't see a reason why that wouldn't work. Is that your exact code, i.e.
> you're not doing anything else between the mysql_query() call and the
> mysql_affected_rows() call? What versions of PHP/MySQL are you using?
>
> ---John Holmes...



Relevant Pages

  • Re: commands out of sync problem
    ... server and client application like this: ... Add a SQLconnection for the MySQL database ... and...tada 'commands out of sync: you can't run this command now'. ...
    (alt.comp.lang.borland-delphi)
  • Re: [SLE] MySQL Table Locked?
    ... Mysql seems to think it is fine. ... > a sql back-up of the one table that's not working ... > Check the headers for your unsubscription address ... For additional commands send e-mail to suse-linux-e-help@suse.com ...
    (SuSE)
  • Converting from MySQL commands to Oracle: HELP!
    ... A colleague has written a prototype program in PHP, using a MySQL ... with a restricted set of mysql commands ... Oracle equivalent, including connecting to the new DB ... mysql_data_seek($arry, $day) ...
    (comp.lang.php)
  • Re: [SLE] MYSQL
    ... When you install mysql a "mysql" daemon user account ... > Check the headers for your unsubscription address ... "Zwei Dinge sind unendlich, das Universum und die menschliche Dummheit, ... For additional commands send e-mail to suse-linux-e-help@suse.com ...
    (SuSE)
  • RE: Remote Console on MySQL
    ... Could be wrong here but I recall a 'system' command that you can use at the mysql> prompt to run OS commands. ... Download FREE whitepaper on how a managed service can ... Download FREE whitepaper on how a managed service can help you: http://www.cenzic.com/news_events/wpappsec.php And, now for a limited time we can do a FREE audit for you to confirm your results from other product. ...
    (Pen-Test)