PHP mysqli_init() Function
In this chapter you will learn:
- Definition for PHP mysqli_init() Function
- Syntax for PHP mysqli_init() Function
- Example - create an object for mysqli_real_connect() function
Definition
The mysqli_init() function initializes MySQLi and returns an object to use with the mysqli_real_connect() function.
Syntax
PHP mysqli_init() Function has the following syntax.
Object oriented style
mysqli mysqli::init ( void )
Procedural style
mysqli mysqli_init ( void )
Example
The following code uses of the mysqli_init() function to create an object for mysqli_real_connect() function.
<?php/*from j av a2s.c o m*/
$con=mysqli_init();
if (!$con){
die("mysqli_init failed");
}
if (!mysqli_real_connect($con,"localhost","my_user","my_password","my_db")){
die("Connect Error: " . mysqli_connect_error());
}
mysqli_close($con);
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_insert_id() Function
- Syntax for PHP mysqli_insert_id() Function
- Parameter for PHP mysqli_insert_id() Function
- Return for PHP mysqli_insert_id() Function
- Example - gets the id used in the last query
- Example - Object oriented style
Home » PHP Tutorial » PHP MySQLi Functions