Popular script sites

The Five Dollar Script Archive HOTScripts.com
Freshmeat.net
cgi-bin.com
MATTs Script Archives
Script Search
Script Resources
Webmaster Scriptz.com

Using PHP to Create a Database Connection Test

Scene: You, banging your head on your computer.... you can't get your script to communicate with the database... you know the error,

Could not connect to MySQL:
Access denied for user 'yourdatabase'@'localhost' (using password: YES)

Host: Your script is messed up...

Script Author: It's your hosting...

You: ARGH!

Here's a small php script that will help you test the script's connection to the database.

Before running the test, make sure to...

  1. Check your hosting account control area (cPanel, Plesk, etc..) and double check that the database is there and that you not only have the user set up, but that you have given permissions to the user for this database. Also ensure you have the right password for the db with no quiet space at the end of it.

  2. Create an empty file with a text editor and save it as dbtest.php

  3. Copy and paste the code below to the file you just created...

  4.     

    Replace localhost with the database server name if your server doesn't use localhost as for your database. Change the username and password with the details you have for your database. Pay careful attention to the quotations. The database name is not necessary.

  5. Upload to the server where the script is to a folder that’s viewable in a browser.

  6. Load the file in your browser...(ie. http://yoursite.com/dbtest.php)

When the script 'communicates' with the database, the resulting page will display ‘Successful connection’. Be sure to give your script installer the URL to the script.

If the script cannot communicate with the database, then you’ll probably see something like:

Warning: mysql_connect(): Access denied for user ‘dbuser’@'localhost’ (using password: YES) in /path/to/mysqltest.php on line 2

OR

Could not connect to MySQL: Access denied for user ‘dbuser’@'localhost’ (using password: YES)

Copy and paste that error and send it to your web host, along with the details of your database.

Don’t forget to remove the file once the situation is resolved.

Replace hostname (usually localhost), username and password with the details you have for your database. There’s no need to add the database name.

4. Upload to your server to a folder that’s viewable via a browser.

5. Load the file in your browser

If a connection is made, the resulting page will display ‘Connection OK’. Talk again with the software vendor and give them the URL to the script.

If a connection cannot be made, then you’ll probably see something like:

Warning: mysql_connect(): Access denied for user ‘dbuser’@'localhost’ (using password: YES) in /path/to/mysqltest.php on line 2
Could not connect to MySQL: Access denied for user ‘dbuser’@'localhost’ (using password: YES)

Copy and paste that error and send it to your web host, along with the details of your database.

Don’t forget to remove the file once the issue is settled.

Free Scripts Index  Back to Free Scripts Index...

What's New?

Support Desk Script

best autoresponder script The BEST Autoresponder.


Don't Be A Victim Of Accidental Plagiarism...Click Here Now And  Get FREE Unlimited Duplicated Content Searches and Minimize Your Risk Of Using Copyrighted Materials!

Link Machine, Link Directory Script


Eco-Friendly Hosting
Sustainable Lifestyle