The MySQLi extension was developed to take advantage of new features found in MySQL systems versions 4.1 and Above. MySQLi is also sometimes known as the MySQL improved extension.The MySQLi extension is included with PHP versions 5 and later.
If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use this extension.
The MySQLi extension has a number of benefits, the key enhancements over the MySQL extension listed below
- Object-oriented interface as well as this extension also provides a procedural interface
- Support for Prepared Statements
- Support for Multiple Statements
- Support for Transactions
- Enhanced debugging capabilities
- Embedded server support
So Today I am going to Write About Connecting to MySQL Server using PHP’s MySQLi Extension.
mysqli_connect() function is used to connect to database,this function returns a link identifier On success, that you can use in other MySQLi functions. On failure, it will throw an error.
MySQLi connection with the object method
MySQLi connection with the procedural method
If your MySQL port is different from default one (3306), you need to give the port number as the fifth parameter.
MySQLi connection with the Port Number
mysqli_connect() throws an error at failure and
mysqli_connect_error() stores the error in last call to
mysqli_connect(). If there is no error, it returns NULL.
Connection error checking
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.