Php:mysqli extension

Source: Internet
Author: User

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

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.