Database connection error (3): Could not connect to database

Do you have a database connection problem, you can check your database connection easily with the following code:


// check database connection
// write your database host / username / password / database name below
// $con=mysqli_connect("host","username","password","database");
// sample for my localhost connection, no password and username is root

$con=mysqli_connect("localhost","root","","25test");

if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else 
echo 'Connection OK'; }
mysqli_close($con);
All you need to do is writing the code in to a PHP file
later upload it to your server. For example, i have my localhost at c://xampp

and my location for php snippets is: c://xampp/htdocs/phpsnippets

after saving this file there i open my browser and test if connection works:

localhost/phpsnippets/checkdatabase.php

If the connection works you get the message: Connection OK

If you get the error message, you need to check:

  • Your Database HostName
  • Your Database Username
  • Your Database User Password
  • Your Database Name


If everything is correct and you still get the error, contact your host!

Database connection error (3): Could not connect to database is a common error


Database connection error (3): Could not connect to databaseis a common error when you enter wrong information 

SPRING PROMO 25%0FF! UNTIL 1ST MAY! USE PROMO CODE NOW : springX Close
This is Floating Toolbar Module by PluginValley