Monday, October 8, 2012

PHP and Database Connection

  Based on how the presentation of information, a web page can be divided into two kinds of the web that are static and dynamic.

   A static web page and displays only the information that same each visitor visits a website. While the dynamic nature of web databases need to be able to manage the information that is required to be presented and used to interact with web visitors.

  Implementation of various applications can be done using a multi-tier models for one or more layers to cooperate.

Model Tree-tiered system:
a. first tier: web client (ex: web browser)
b. Second tier: web server, PHP scripts, connectivity API, and CGI scripts
c. Third tier: database server (MySQL, Oracle, PostgreSQL)

  In order to access a MYSQL table into the programmer must, perform a first connection that can be connected in the form of scripts PHP.

Example PHP script database connection:
<?php
  $koneksi=mysql_connect("localhost","root","");
  if ($koneksi) {
     }
  else {
     }
  mysql_select_db("databasename") or die(mysql_error()); 
?>


1 comment: