How do I Connect a website in MySql?

  • Home How do I Connect a website in MySql?
How do I Connect a website in MySql?

How do I Connect a website in MySql?

July 5, 2009

Question:
How do I Connect a website in MySql?

Answer:
If you want to connect your website to a MySQL database. There are a number of steps.

  1. You must make sure your hosting company offers that service and that you have that feature on your current hosting account.
  2. You must create the database with a user name and password. You can manipulate your database(s) using a program called phpMyAdmin. This is usually provided by your host company.
  3. Youmust use a scripting language to connect with. Usually of you are using MySQL then the language will be PHP.
  4. You then create the php page and upload it up to your sever.
  5. The following sample will allow you to connect your php page to the database. It does NOT do anything else other than connect. There are too many other variables on the type of table created and what you may want to do to show a general example.

Example:
<?php

//Usually this is localhost. But could be an address of the database server
$HostType = "locahost";

//Name of your database
$DatabaseName = "SomeName";

//Your database username
$DbaseUsername = "SomeUsername";

//Your database password
$DbasePassword = "SomePassword";

$db=mysql_connect($HostType,$DbaseUsername,$DbasePassword);
mysql_select_db($DatabaseName,$db) or die ("cant change");


//code to manipulate the data base

?>

About the Author
Rich Agnew is an author for The Computer Geek Custom Web Page Design. The Computer Geek is a web design company that prides itself in professional service at a fraction of the cost. The Computer Geek specializes in Custom Web Design, PHP & MySql and Ecommerce.

To Make a Request For Further Information

5K

Happy Clients

12,800+

Cups Of Coffee

5K

Finished Projects

72+

Awards
TESTIMONIALS

What Our Clients
Are Saying About Us

Get a
Free Consultation


LATEST ARTICLES

See Our Latest
Blog Posts

How 5G Will Transform Industries in the Coming Years
December 21, 2024

How 5G Will Transform Ind

The Importance of Brand Storytelling in Marketing
December 20, 2024

The Importance of Brand S

Intuit Mailchimp