MYSQL AND PHP FAQ


  1. How can I manage my database via the web?
  2. How do I use PHP to connect to MySQL?
  3. How do I use phpMyAdmin?
  4. How can I create a MySQL database?
  5. Do you have any additional help files for beginners for MySQL database management?
  6. My PHP program tells me it can't access the database because of incorrect username/password. I've checked the configuration settings in my script and everything's in there as I created them.

1. How can I manage my database via the web?

We have installed a powerful web interface that makes it very easy to administer your database. This interface, called phpMyAdmin, is based on the PHP scripting language and lets you create, drop, edit, and manage tables and data in your MySQL database. You can read more on phpMyAdmin by going to phpMyAdmin . A demo of phpMyAdmin is available at http://www.phpmyadmin.net/home_page/demos.php.

2. How do I use PHP to connect to MySQL?

To merely display the information in your database without the use of a form to call a php script, you simply create your HTML document as you would any other web page but instead of the extension of .htm or .html you need to name the file with the extension .php. Then within the document itself, for the section that you'd like to use the PHP code, you begin it with <?php and end it with ?>.

3. How do I use phpMyAdmin?

Click "MySQL Databases" icon. You can see a 2-minute Flash tutorial about how to do this HERE. Then go down to the phpMyAdmin link at the bottom of the MySQL Databases page. This will take you to the phpMyAdmin interface where you can work with your MySQL database/s.
To see the tutorial of "How to manage database with PHPMyAdmin" click HERE

NOTE: You should know something about MySQL or other relational databases before you try to work with phpMyAdmin. phpMyAdmin does not stop the user from entering incorrect syntax, therefore it will accept a line like the one below even though it is incorrect:

Bad: ALTER TABLE bmt_userinfo ADD first_name TEXT (25) not null , ADD last_name TEXT (25) not null , ADD address1 TEXT (100) not null , ADD address2 TEXT (100) not null , ADD city TEXT (30) not null;

However the same line minus the text length does work:

Good: ALTER TABLE bmt_userinfo ADD first_name TEXT not null , ADD last_name TEXT not null , ADD address1 TEXT not null , ADD address2 TEXT not null , ADD city TEXT not null;

This is because "TEXT" is a set length. The thing to remember is that any syntax that will not work on the command line will not work in phpMyAdmin either. A good place to find out correct syntax for a command that you want to perform is http://www.mysql.com/documentation/index.html

4. How can I create a MySQL database?

Click "MySQL Databases" icon, type a name in db: box and click "ADD DB" button. Then all you need to do is add the user into the database. See our cPanel Tutorial for a graphic demo of how to do this.

5. Do you have any additional help files for beginners for MySQL database management?

Additional information that will help you manage MySQL is located here

6. My PHP program tells me it can't access the database because of incorrect username/password. I've checked the configuration settings in my script and everything's in there as I created them.

When you create your MySQL database, first you create a database by giving it a name. Then you create a user by entering a username and password. For best results keep your database name, database username, and database password at no fewer than 6 and no more than 7 letters or numbers. Then you must be sure to add the user to the database.

In your script, your database name and your database username must be prefaced by your hosting account username_. Your password, however, stands alone. For example: If your hosting account username is "joedoe1", your database name is "testdb", your database username is "dbuser", and your database password is "passwd", here is how you need to put them in your script:

database server should usually be localhost
database name should be written as joedoe1_testdb
database username should be written as joedoe1_dbuser
database password should be written simply as passwd


As always, if you need any help at all, feel free to email us at support@canadianwebhosting.com or post a question in our Support Forums.