View Full Version : New bie!!!stack after database creation
i have created my mysqldatabase using phpmyadmin, what should i do now to connect it to my website html code? :confused:
pilotdoofy
7-15-04, 09:05 PM
First off you don't connect MySQL to HTML. You have to have a dynamic/programming language to use database input, HTML is simply a markup language.
If you want to go about doing it in php I can definitely help you. I'll show you some basic steps how to connect but if you want more detail either buy a book on it, research it, or AIM or email me. AIM = pilotdoofy and email = mdaniel@mustywindows.com so there I made it easy for you.
To connect to your database with php there are two ways of establishing the connection statement. The first way would be to specify the connection statement on each page you need the database input for. While this is insecure and hassling I don't chose this method, but if you here is how you would do it.
<?
//connect to the database by select variables
$host = "mysql.yourhost.com";
$db = "your database";
$user = "username for your mysql host";
$password = "your password";
?>
That is how you establish the variables to connect, here is the connection statement.
<?
//connect to the database here
mysql_connect($host, $user, $password);
mysql_select_db($db);
//insert your SQL or whatever here
?>
But to have neater and safer code embed the variables into a seperate page called connect.php or something similar and store it in the root path of your host's server.
You'd then connect like this:
<?
require("/rootpath/connect.php");
mysql_connect($host, $user, $password);
mysql_select_db($db);
?>
Or you can also use the include(); function instead of the require(); function. Doesn't really matter in this situation.
I hope that helped. Contact me if you need further php/mysql help.
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.