I got some problem with mysqli_affected_rows, it return 1 all times even update not effected.
$dbConnect = mysql_connect($dbHost, $dbUser, $dbPass);
$dbSelect = mysql_select_db($dbName, $dbConnect);
$sqlprove = mysql_query('UPDATE '.tblAVB.' SET a= "1" WHERE id= "'.$_POST['id'].'" AND Active = "1" ');
$isprove = mysqli_affected_rows($sqlprove);
can any body help me?
If you're using mysqli
then you use only mysqli
prefixed functions. You cannot mix and match with the deprecated mysql_query
methods.
In fact, you should not be using mysql_query
at all if you're using mysqli
.
If you're just getting started you should be using PDO instead. The mysqli
interface is better than the legacy one, but it's fairly annoying and cantankerous compared to PDO.
In any case, you must be very careful to always use proper SQL escaping on any and all values.
i have this one, it work but i don't want to use Object oriented style in middle of the codes:
$mysqli->query('UPDATE '.tblAVB.' SET a= "1" WHERE id= "'.$_POST['id'].'" AND Active = "1" ');
$prove = $mysqli->affected_rows;
and the Procedural style not work!!!!! because i connect it to db before query and not use $link!!!!
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
mysqli_query($link, "UPDATE Language SET Status=1 WHERE Percentage > 50");
printf("Affected rows (UPDATE): %d\n", mysqli_affected_rows($link));
is it because i use mysql rather mysqli? is there a way to get affected_rows for mysql? reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.