![]() ![]() We can make the connection using the MYSQLi in two ways. Example 2 – PHP MYSQL Connection Using MYSQLi That’s why we should avoid using this technique to make a database connection in PHP language to the MySQL database. But, if we use this code, it says Deprecated: mysql_connect() : The MySQL extension is deprecated and will be removed in the future: use mysqli or PDO instead. The connection can be made successfully in the lower version of PHP. mysql_error()) Įcho "Database Connected successfully" // in case of success $link = mysql_connect($servername, $username, $password) ĭie('Connection failed: '. Given below are the examples mentioned: Example 1 – PHP MYSQL Connection using MYSQL The moment we create a connection, it gives us the object to deal with the MySQL related. ![]() This one is considered as an object-oriented way of communicating with the MySQL database. Usually, we consider this as the best approach out of these three. This will work with the MySQL database only, but this is an improved version of MySQL. Now, every coming PHP version has deprecated this approach. This extension follows the old traditional way of communicating with a database. This will work with the MySQL database only. In the PHP language, we can make database connection in a below-mentioned way: 1.
0 Comments
Leave a Reply. |