Saturday, May 21, 2011

How do I Connect a website in MySql?

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.
You must make sure your hosting company offers that service and that you have that feature on your current hosting account. 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. Youmust use a scripting language to connect with. Usually of you are using MySQL then the language will be PHP.

You then create the php page and upload it up to your sever. 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

?>
source:computergeek

0 comments:

About Me

My Photo
Daniel "adoy"
I'm a stricly Comedian, I write to open your insights about what is happening in the world of computerization.
View my complete profile

Blog Archive