Preprocessing technology of Mysqli extended library mysqli stmt

Source: Internet
Author: User

Principle of thinking

The code is as follows:

1<?PHP2        //Pre-compiled demo3 //requirements: Use preprocessing to add three users to a database4 //1. Creating a Mysqli Object5        $mysqli=NewMysqli ("localhost", "root", "hsp123", "Test");6        //2. Creating Precompiled Objects7       $sql = "INSERT INTO User1 (name,password,email,age) VALUES (?,?,?,?)";8        $mysqli _stmt= $mysqli->prepare ($sql) or Die ($mysqli->error);9        //Binding ParametersTen        $name= "Xiao Qian"; One        $password= "Xiaoqian"; A        $email= "[Email protected]"; -        $age= "200"; -        //parameter binding, assign value, here the type and order are to correspond. the        // -        $mysqli _stmt->bind_param ("SSSI", $name, $password, $email, $age); -        //Execution -  $b = $mysqli _stmt->execute (); +        -        //continue to add +        $name= "Old Demon"; A        $password= "Laoyao"; at        $email= "[Email protected]"; -        $age= "210"; -        $mysqli _stmt->bind_param ("SSSI",$name,$password,$email,$age); -        //Execution -        $b=$mysqli _stmt-execute (); -        in        //continue to add -        $name= "Vegetable Layer"; to        $password= "AAA"; +        $email= "[Email protected]"; -        $age= "30"; the        $mysqli _stmt->bind_param ("SSSI",$name,$password,$email,$age); *        //Execution $        $b=$mysqli _stmt-execute ();Panax Notoginseng        if(!$b){ -                die("Operation failed".)$mysqli _stmt-error); the}Else{ +               Echo"Operation OK"; A        } the        //Release +        $mysqli-close (); -?>

Preprocessing technology of Mysqli extended library mysqli stmt

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.