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
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

Adding data to table :

To add data to table, we need to build and execute a SQL query. PHP provides the mysql_query() function for that purpose. mysql_query() requires two inputs: first, the SQL query and second, a link identifier. Identifer is optional. If omited, then query is sent to the database server to which you last connected.
mysql_query() returns true if the query executes successfully. If there are any syntax errors or if you do not have permission to access database, then it return false.

Code 4 :- adddata.php
<html>
 <head>
  <title>Server test Page </title>
 </head>
 <body>
  <p>Display data from MySQL Database.</p>
  <?php
   $link = mysql_connect("mysql_host", "mysql_user", "mysql_password") or die("Could not connect : " . mysql_error());
   print "Connected successfully<p>";
   $DB = "user";
   $table = "visitor";
   mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error());
   print "Successfully select the Database: $DB ";
   $query = "INSERT INTO $table(name,address,email) values('max','nagpur',' This e-mail address is being protected from spam bots, you need JavaScript enabled to view it ')";
   if ( ! mysql_query( $query, $link) )
    die ( "MySQL error.....<p>" .mysql_error() );
   print "<p>Successfully data added to table : $table";
  ?>
 </body>
</html>

The adddata.php produces output as shown in Output-4.

Output 4: adddata.php
Display data from MySQL Database.
Connected successfully
Successfully select the Database: user
Successfully data added to table : visitor



Last Updated ( Tuesday, 13 March 2007 )
 

Who's Online

We have 1 guest 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: 374430

Google Seach

Google AdSense

TechXcel Referrals

TechXcel's Sponcer...