Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Web Design Pricing Dreamweaver Templates Web Applications Free Tutorials About Contact Us
Services > CSS Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Logo Design Portfolio | Web Design Pricing > Custom Web Design | Logo Design | Business Card Design
Web Design Guide > Website Design w/ Dreamweaver & Fireworks | Fireworks CS4 Cool Features | Photo Effects | Text Effects | Graphic Design Ideas | Web Design Ideas
Website Navigation Ideas | CSS Styles Tutorial | Dreamweaver Template | Server Side Includes | Flash Tutorials > Flash Effects | Flash Sound Button | Sound On/Off Button
Flash Preloader | Import External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

Connecting to MySQL database:

It is always a good practice to write the connection string for the database in a separate file and call it on each page where the the database is required. To know how to call the file see PHP Tips (Server Side Includes).

So we first create a file where we assign the values for your server, the database you want to connect,the user name and the password to variables. Let us save this file as conn.php

<?php
$strServer="66.9.65.200"; // Server IP Address Or Name
$strDatabase="database name"; // Database Name
$strUser="root"; // User ID
$strPwd="pwd";// Password
?>

Now we can call

The syntax to connect to the server or Opening a database connectivity is

$strDB=mysql_connect("ServerIP Address","Username","Password")

For the above example we would write

$strDB=mysql_connect($strServer,$struser,$strPwd);

To connect to the database the syntax is

mysql_select_db("Database Name",$strDB)

For the above example we would write

$database=mysql_select_db("strDatabase",$strDB)

The syntax for closing the Database connection is

mysql_close(Result Connection ID)

For the above example we would write

mysql_close($strDB)

On a whole the code would look like this

<?php
include("conn.php")
$strDB=mysql_connect($strServer,$struser,$strPwd);
$database=mysql_select_db("$strDatabase",$strDB);

mysql_close($strDB)
?>

conn.php

<?php
$strServer="66.9.65.200"; // Server IP Address Or Name
$strDatabase="databasename"; // Database Name
$strUser="root"; // User ID
$strPwd="pwd";// Password
?>

 

Beauty Templates | Business Templates | Christian Templates | CSS Templates | Education Templates | Family Templates | Flash Templates | Free Dreamweaver Templates
Food Templates | General Templates | Government Templates | Health/Medical Templates | Hi-Tech Templates | Kids/Childcare Templates | Low-cost Budget Templates
Personal Templates | Pets Templates | Photography Templates | Profession Templates | Real Estate Templates | Sports Templates | Telecom Templates | Travel Templates
Free Tutorials > Web Design Tutorials | CSS Web Design | Fireworks Tutorials | Dreamweaver Tutorials | Flash Tutorials | SEO Tutorials | Javascript Tutorials | PHP Tutorials