php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7438 mysql_affected_rows not working
Submitted: 2000-10-24 16:46 UTC Modified: 2000-10-25 16:33 UTC
From: juancho at metallica dot com Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0.3pl1 OS: Mandrake 7.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juancho at metallica dot com
New email:
PHP Version: OS:

 

 [2000-10-24 16:46 UTC] juancho at metallica dot com
./configure' '--with-apache=../apache_1.3.14' '--enable-track-vars' '--enable-ftp' '--enable-trans-sid' '--disable-debug' '--enable-magic-quotes'

<?
$conn=mysql_ponnect("localhost","user","pass");

$r=mysql_db_query("mydb","update x='y' where z='p' ",$conn);

$n=mysql_affected_rows($r);

echo "n= $n";
?>
It prints "n= " and I get this warning:
Warning: Supplied argument is not a valid MySQL-Link resource in /mnt/clientes/sancho/html/classes/manage_users.php on line 143

but the data in the database is beeing modified by the update query. It worked fine with 4.0.1pl2

php.ini:

[MySQL]
mysql.allow_persistent	=	On	
mysql.max_persistent	=	-1	
mysql.max_links			=	-1	
mysql.default_port		=		
mysql.default_host		=		
mysql.default_user		=		
mysql.default_password	=		

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-24 16:51 UTC] juancho at metallica dot com
sorry, the correct query is "update mytable set x='y' where z='p' "
 [2000-10-25 16:33 UTC] torben@php.net
This is not a bug--mysql_affected_rows() takes as its argument a link
identifier (i.e., what you get from mysql_pconnect()), and not a result
identifier. Try passing $conn instead of $r and you should get what
you want.

Hope this helps.
 [2012-02-07 13:16 UTC] cbal at freemail dot hu
see this:
http://stackoverflow.com/questions/7303304/mysql-affected-rows-does-not-work-for-checking-if-row-exists

this solves the problem
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 00:01:31 2025 UTC