Why does mysqli not prompt a field error? This post was last edited using mysqli, not mysql & nbsp; (mysql is Prompted) for example, query (update & nbsp; {$ tpre} member & nbsp; set & nbsp; tt & nb mysqli does not prompt a field error
This post was last edited by gomms at 21:48:01, September 29 ,.
Note that mysqli is used, not mysql (mysql is prompted)
For example:
query("update {$tpre}member set ttid='2000' where userid123='10000'");
There is no userid123 field. during execution, there is no update, but no error is prompted.
How can I prompt it for an error without this field?
Use MYSQL5.7 and php5.6
------ Solution ----------------------
An object-oriented error is thrown:
$ Mysqli = new mysqli ("localhost", "my_user", "my_password", "world ");
/* Check connection */
If ($ mysqli-> connect_errno ){
Printf ("Connect failed: % s \ n", $ mysqli-> connect_error); // mysql connection error thrown
Exit ();
}
If (! $ Mysqli-> query ("SET a = 1 ")){
Printf ("Errormessage: % s \ n", $ mysqli-> error); // mysql Query error thrown
}
?>
Process-oriented errors are thrown:
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if (!mysqli_query($link, "SET a=1")) {
printf("Errormessage: %s\n", mysqli_error($link));
}
?>
------ Solution ----------------------
$ Mysqli = new mysqli ("localhost", "my_user", "my_password", "world ");
/* Check connection */
If (mysqli_connect_errno ()){
Printf ("Connect failed: % s \ n", mysqli_connect_error ());
Exit ();
}
// $ Mysqli-> affected_rows get the number of rows affected by the previous MySQLI operation
$ Mysqli-> query ("update {$ tpre} member set ttid = '000000' where userid123 = '000000 '");
Printf ("Affected rows (UPDATE): % d \ n", $ mysqli-> affected_rows );
$ Mysqli-> affected_rows can obtain the number of rows affected by the previous mysqli operation in MySQLI.