Home page Forum

Go Back   MyServerZone » Installiation & Config » DataBases

Reply
 
LinkBack Thread Tools Display Modes
Old 11-23-2008, 01:37 PM
Administrator
 
KING's Avatar
 
Join Date: Nov 2008
Posts: 23
Send a message via ICQ to KING Send a message via Yahoo to KING Send a message via Skype™ to KING
Default Mysql connection php

Simple mysql connection from PHP:

Create file config.php in file insert this lines and edit by your server configuration.:
Code:
<?php
$db_host="localhost";   // Mysql hostname ( by default it should be localhost)
$db_user="username";  // Mysql username 
$db_pass="password"; // Mysql password
$db_name="database"; // Database
?>
Now create file to connect to your database.
Create file database.php and insert this lines:
Code:
<?php
db_connect(); // I created funcion to connect to mysql because it much more easy to use.
function db_connect()
{
    include('config.php'); // This line will include config.php to get configuration.
    if(!mysql_connect($db_host,$db_user,$db_pass)) er_exit(mysql_error()); 
    if(!mysql_select_db($db_name)) er_exit(mysql_error());
}
?>
KING is offline   Reply With Quote
Sponsored Links
Reply

« - | - »
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:04 PM.