Want to make database connection to MySQLi in PHP. Use the following PHP code to connect database using MySQLi in PHP programming language.
1 2 3 4 5 6 7 8 9 10 11 | /** * Make database connection to mysqli in PHP. */ $con = mysqli_connect("localhost","my_user","my_password","my_db"); // Check DB connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.