Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
Connecting to a Database (0 Comments)
Admin: Posted Date: March 3, 2010

You need to have a connection to mysql before you can send and recieve data. This first code will define the DB variables, so you will need to enter all of your database info!

Connecting to a Database

You need to have a connection to mysql before you can send and recieve data. This first code will define the DB variables, so you will need to enter all of your db info!

CODE

<?php
$localhost ="localhost";
$dbuser="your_db_name";
$dbpass= "your_db_pass";
$dbname = "your_db_name";


This next code is the code that you´ll need to make the connection. You don´t need to set the variables again

CODE

mysql_connect($localhost, $dbuser, $dbpass) or die
(mysql_error());
@mysql_select_db ("$dbname") or die(mysql_error());


Thats all, but don´t forget this: ?> ;)

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: