Skip to content

TechXcel.com - provides technical excellence...

Narrow screen resolution Wide screen resolution Increase font size Decrease font size Default font size default color orange color green color
You are here: Home arrow PHP arrow PHP Database Integration With MySQL
PHP Database Integration With MySQL PDF Print E-mail
(8 votes)
The Article - php
Written by Chetankumar Akarte   
Wednesday, 07 March 2007
Article Index
PHP Database Integration With MySQL
Create New Database
Select MySQl Database
Adding Data to Table
Retrive Data
Error Handing
Source Code

One of the defining features of PHP is the versatility it offers for connection to, and manipulation with, databases. In this article, we look at some features of the PHP and MySQL combination. We shall go through the following steps:-

  • Connect to MySQL Database Server 
  • Create new Database 
  • Select MySQL Database 
  • Add data to table 
  • Retrieve data 
  • Error Handling

Connect to MySQL Database Server:

To work with the MySQL database, we first need to connect to MySQL Database Server. PHP provides mysql_connect() function to do this, and requires three strings as input: ‘hostname’, ‘username’ and ‘password’. Use Code-1 to connect to MySQL Database Server.

Code 1: test.php
<html>
 <head>
  <title>Server test Page </title>
 </head>
 <body>
  <p>Testing working of MySQL.</p> 
  <?php
   /* Connecting to MySQL */
   $link = mysql_connect("mysql_host", "mysql_user", "mysql_password") or die("Could not connect : " . mysql_error());
   print "Connected successfully";
  ?> 
 </body>
</html>


If your script has no error, then Code-1 gives output as:

Output 1: test.php
Testing working of MySQL.
Connected successfully



Last Updated ( Tuesday, 13 March 2007 )
 

Who's Online

User Login

PayPal Donation

Enter Amount:

Syndicate

TechXcel's Friends

Tutorials Garden
Wicolorz
pixel2life

Text Link Add

Statistics

Members: 295
News: 60
Web Links: 6
Visitors: 373724

Google Seach

Google AdSense

TechXcel Referrals

TechXcel's Sponcer...