Why does mysqli not prompt a field exception?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.