iSelfSchooling.com - Since 1999  References  |  Job Openings  |
    Home  | Search more  | Oracle Syntax  | Instructor-Led in Class   | (Members to access to VIDEOS)
 

Copyright & User Agreement

   Suggestions Email2aFriendHomepage us! |  Bookmark

Services

  Vision/Mission

  Services

  Biography

  Contact Us

 FREE Training

  Start...

  SQL

  PL/SQL

  Forms 

  Reports

  DBA Fundamentals

  Performance

  Prepare for OCP

  ShareUrNotes

...

  Acknowledgement

  Who is who

  University Directory

  Links...

 

 

 

How to use read or write to Oracle, SQLServer, MySQL, or other databases in PHP?

More Resources by Google:

How to use read or write to Oracle, SQLServer, MySQL, or other databases in PHP?


To get more information about SQL go to www.mysql.com <http://www.mysql.com> , www.oracle.com <http://www.oracle.com> , www.phpmyadmin.net <http://www.phpmyadmin.net> and more. The www.iselfschooling.com <http://www.iselfschooling.com> website is the best website that will teach you how to write a SQL statement step by step. It has a movie that you can play and watch. All their training courses are downloadable.

The following PHP script is an example of how to connect and insert a record into a database (MySQL DBMS). The same concept can be used for Oracle, SQLServer and other databases.
We assume that you know SQL statement. If you want to learn more about the SQL statement and its syntax, please go to www.iselfschooling.com <http://www.iselfschooling.com> with lots of examples and FREE tutorial pages.

In this example, we display and handle the HTML form in the same script. We add a record to the “customer” table, and then we display the added record. It contains three columns such as customer_id, customer_name, and customer_address. We call this script “database_transaction.php.”


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitionl.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>An example of database transaction in PHP.</title>
</head>

<body>

<?php // database_transaction.php
init_set(‘display_errors’,1); // turn on my display error option
error_reporting(E_ALL); // Turn on all the errors 

if (isset ($_POST[‘submit’])) { // if the user submit the form then
if ($db_connect = @mysql_connect (‘your-hostname’,’username’,’password’)) { 
if (!@mysql_select_db 


// if can you connect, then add a record.
$transaction = “INSERT INTO customer 
(customer_id, customer_name, customer_address)
VALUSE (100, ‘{$_POST[‘customer_id’]}’,
‘{$_POST[‘customer_name’]}’,
‘{$_POST[‘customer_address’]}’);
// execute transaction.
if (@mysql_query ($transaction)) { 
print ‘<p>Record was added successfully.</p>’;
} else {
print “<p>Record was not added because, <b>” . mysql_error() . “</b>”;
}

Mysql_close(); // close the database.
}
}
?>

<form action=”database_transaction.php” method=”post”>
<p>Enter Customer ID: <input type=”text” name=”customer_id” size=”10” maxsize=”10” /></p>
<p>Enter Customer Name: <input type=”text” name=”customer_name” size=”10” maxsize=”100” /></p>
<p>Enter Customer address: <input type=”text” name=”customer_address” size=”10” maxsize=”100” /></p>
<input type=”submit” name=”submit” value=”Add customer.” />
</form>

</body>
</html>

 

 

 
 
Google
 
Web web site