You are not logged in or registered. Please login or register to use the full functionality of this board...

Post Reply 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to test if MySQL database is working
07-14-2011, 06:07 PM
Post: #1
How to test if MySQL database is working
There is a simple way that you can test whether or not you can establish a connection on your MySQL database with your created username and password

Simply create a .php file (e.g. connect.php) with the following code:

mysql_connect("localhost", "db_username", "db_passwd") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("db_name") or die(mysql_error());
echo "Connected to Database";

Note that you need to replace

db_username with the username associated with the database
db_passwd with the password for the database user


db_name with the name of the database you have created

When you upload the file, point your web browser to (replacing 'connect.php' with the name of the php file you saved it as) and it should print to the screen with success assuming that it managed to connect.
Find all posts by this user
Quote this message in a reply
Post Reply 

Forum Jump:

User(s) browsing this thread: 1 Guest(s)