Note: The steps below is if you’ve already created a database, if you don’t have one yet, please click the guided link on how to create a database. |
When you have installed or created your database for your website, you can check the connection using a PHP script. You can create a file called ‘testdb.php‘ or any desired file name and access it with your website.
Here are the steps and script to test your MySQL Connection:
1. Open a notepad or any note editor from your computer.
2. Copy and paste the script below:\
<?php $servername = “localhost”; $username = “username”; $password = “password”; // Create connection // Check connection |
Important: Change values for ‘username’ and ‘password’ with your database information. Keep ‘localhost’ as is. |
3. Save the file as ‘testdb.php‘ or any desired file name. Upload it to your ‘public_html‘ or the desired directory.
4. Access your website by going to http://yourdomain.com/testdb.php. Or depends on which directory the domain name is pointed to.
You’ll see the message above, if the connection is successful. If it has failed, you’ll be prompted with Connection failed message.
Please don’t hesitate to contact our 24/7 Singapore or Australia Support Team if you have further queries.