Website Domain Registration and Website Hosting - Host a Website Tonight
GoWebsite.com provides Domain Registration
Website Hosting, On-Line Shopping Carts, SEO
Blog Hosting, Email Accounts, Security Certificates,
Merchant Accounts & other Website Products.
Free setup! Speak with us anytime: 480-624-2500

Connecting to MySQL Using PHP

There are two main steps to connecting to a MySQL database using PHP.

First, connect to your MySQL server using the mysql_connect statement. For example:

$con = mysql_connect('HOSTNAME','USERNAME','PASSWORD');

You can log in to your hosting account manager to find the hostname, user name, and password for your database.

Next, select the database that you want to access using mysql_select_db. For example:

mysql_select_db('DATABASENAME', $con)

Where "DATABASENAME" is the name of your database. Again, you can log in to your hosting account manager to find the name of your database. The name of your database is usually the same as the user name for that database.

From here, you can query your database using your PHP script.

For more information, take a look at our Complete PHP/MySQL Example.

Domain Registration Domain Registration
Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. Everything you need to get online - FREE with your domain.
Website Hosting Website Builder
For as little as $3.89 per month you can build your Website online with Website Builder using our easy to use professional templates.
Play Video - Demo
Shopping Cart Software Quick Shopping Cart
Build and run your own successful online store in minutes! You're just five easy steps away!
Play Video
Website Hosting Website Hosting
Everything you need to give your Website the high-performance home it deserves!  Protect transactions and customer data with a
SSL Certificate