Mysqli Features Overview: http://php.net/manual/zh/mysqli.summary.php
Code (basic usage): Seemingly preventable SQL injection
$root= "Root"; $pwd= ""; $host= "localhost"; $database= "VVTSS"; //object-oriented way to instantiate an object $conn=NewMysqli ($host,$root,$pwd,$database); //return 0 means no error occurred if(Mysqli_connect_errno()){ Echo' Database connection failed with error code: '.Mysqli_connect_errno(); die; } $id=$_get[' ID ']; $username=$_get[' username ']; //One of these? is a placeholder $sql= "SELECT * FROM table_name WHERE id =?" and username =? "; //Perform preprocessing operations $search _action=$conn->prepare ($sql); //binding parameters, the first parameter is represented as the number of pre-processed placeholders and the data type of each parameter, S is a string, I is shaped, D is a double-precision decimal, there are several parameters, write several s or D or I, for example Iiii,ssss,sidi. Then there are a few parameters to write several variables to bind, such as Bind_param (' SSS ', $username, $password, $code); $search _action->bind_param ("SS",$id,$username); //bind the result to the corresponding variable, such as you select Username,password, you can write Bind_result ($usernmae, $password); $search _action->bind_result ($columns); Execute SQL Operation $search _action-execute (); $result=$search _action-Get_result (); while($rows=$result-Fetch_assoc ()) { Var_dump($rows); } $search _action->free_result ();//Freeing Memory $search _action->close ();//end of this instantiation
The follow-up complex needs to be perfected ........ .......
Php:mysqli extension