Mysqli is a function after php5, no extension can be opened by a friend to open your php.ini configuration file.
Look for the following statement:Extension=php_mysqli.dll Modify it to:Extension=php_mysqli.dll .
There are many new features and benefits compared to MySQL
(1) Support local binding, preparation (prepare) and other syntax
(2) Error code to execute SQL statement
(3) Execute multiple SQL simultaneously
(4) An object-oriented calling interface method is also provided.
Below one by one use PHP instance for mysqli database connection!
Use method one: Using the traditional process-oriented approach
The PHP code is as follows:
<? php $connect = mysqli_connect (' localhost ', ' Root ', ', ' volunteer ') or die (' Unale to connect ' $sql = "SELECT * from Vol_msg" ; $result = mysqli_query ( $connect , $sql while ( $row = mysqli_fetch_row ( $result echo Span style= "COLOR: #800080" > $row [0];} ?
Using method Two: Invoking an interface using an object-oriented method (recommended)
Look at the PHP code as follows:
<?PHP//create the object and open the connection, and the last parameter is the name of the selected database$mysqli=NewMysqli (' localhost ', ' root ', ' ', ' volunteer '));//Check if the connection is successfulif(Mysqli_connect_errno()){ //Note Mysqli_connect_error () new features die(' Unable to connect! ').Mysqli_connect_error();}$sql= "SELECT * FROM Vol_msg";//Execute SQL statements, fully object-oriented$result=$mysqli->query ($sql); while($row=$result-Fetch_array ()) { Echo $row[0];}?>
The above two PHP instances run exactly the same results, and you can clearly see the benefits of building a database connection using the Mysqli class Object! Inserting and modifying records I don't have to talk about it, just change the SQL statement, next I'll talk about prepare interface features!
Http://www.phpddt.com/db/286.html
Two methods of mysqli database connection in PHP