PHP mysqli_ssl_set() Function
In this chapter you will learn:
- Definition for PHP mysqli_ssl_set() Function
- Syntax for PHP mysqli_ssl_set() Function
- Parameter for PHP mysqli_ssl_set() Function
- Return for PHP mysqli_ssl_set() Function
- Example - establishes secure connections using SSL for the enabled OpenSSL support
Definition
PHP mysqli_ssl_set() Function creates an SSL connection.
Syntax
PHP mysqli_ssl_set() Function has the following syntax.
mysqli_ssl_set(connection,key,cert,ca,capath,cipher);
Parameter
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection to use |
key | Required. | Path name to the key file |
cert | Required. | Path name to the certificate file |
ca | Required. | Path name to the certificate authority file |
capath | Required. | Pathname to a directory that contains trusted SSL CA certificates in PEM format |
cipher | Required. | A list of allowable ciphers for SSL encryption |
Return
Returns TRUE on success or FALSE on failure.
Example
The mysqli_ssl_set() function establishes secure connections using SSL for the enabled OpenSSL support. This function must be called before mysqli_real_connect().
<?php/* j av a2s. com*/
$con=mysqli_init();
if (!$con){
die("mysqli_init failed");
}
mysqli_ssl_set($con,"key.pem","cert.pem","cacert.pem",NULL,NULL);
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_stat() Function
- Syntax for PHP mysqli_stat() Function
- Example - Get the current system status
Home » PHP Tutorial » PHP MySQLi Functions