Share on Google+Share on Google+

PHP MySQLi Affected Rows

In this current tutorial we will study how to connect PHP and MySQLi but before that we will study what is MySQLi extension in PHP.


This is a method of mysqli by which we can get the number of affected rows in the previous MySQL  operation.

There are two formats are available for this  of the method is as follows:

Object Oriented Style (property):

mysqli, int $affected_rows.

Procedural Style:

int mysqli_affected_rows(mysqli $link)



$db=new mysqli("localhost","root","","university");



printf("Connect failed:%s \n",mysqli_connect_error());



$result=$db->query("select name from student");

printf("Affected rows:%d \n",$db->affected_rows);


Affected rows:-1


Posted on: May 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.