MySQL Database Handling in PHP

Written by John L

Most interactive websites nowadays require data to be presented dynamically and interactively based on input fromrepparttar user. For example, a customer may need to log into a retail website to check his purchasing history. In this instance,repparttar 105568 website would have stored two types of data in order forrepparttar 105569 customer to performrepparttar 105570 check –repparttar 105571 customer’s personal login details; andrepparttar 105572 customer’s purchased items. This data can be stored in two types of storage – flat files or databases.

Flat files are only feasible in very low to low volume websites as flat files have 3 inherent weaknesses: 1.The inability to indexrepparttar 105573 data. This makes it necessary to potentially read ALLrepparttar 105574 data sequentially. This is a major problem if there are a lot of records inrepparttar 105575 flat file becauserepparttar 105576 time required to readrepparttar 105577 flat file is proportionate torepparttar 105578 number of records inrepparttar 105579 flat file. 2.The inability to efficiently control access by users torepparttar 105580 data 3.The inefficient storage ofrepparttar 105581 data. In most cases,repparttar 105582 data would not be encrypted or compressed as this would exacerbaterepparttar 105583 problem no. 1 above

The alternative which is, in my opinion,repparttar 105584 only feasible method, is to storerepparttar 105585 data in a database. One ofrepparttar 105586 most prevalent databases in use is MySQL. Data that is stored in a database can easily be indexed, managed and stored efficiently. Besides that, most databases also provide a suite of accompanying utilities that allowrepparttar 105587 database administrator to maintainrepparttar 105588 database – for example, backup and restore, etc.

Websites scripted using PHP are very well suited forrepparttar 105589 MySQL database as PHP has a custom and integrated MySQL module that communicates very efficiently with MySQL. PHP can also communicate with MySQL throughrepparttar 105590 standard ODBC as MySQL is ODBC-compliant, However, this will not be as efficient as usingrepparttar 105591 custom MySQL module for PHP.

The rest of this article is a tutorial on how to use PHP to: 1.Connect to a MySQL database 2.Execute standard SQL statements againstrepparttar 105592 MySQL database

Starting a Session with MySQL

Beforerepparttar 105593 PHP script can communicate withrepparttar 105594 database to query, insert or updaterepparttar 105595 database,repparttar 105596 PHP script will first need to connect torepparttar 105597 MySQL server and specify which database inrepparttar 105598 MySQL server to operate on.

The mysql_connect() and mysql_select_db() functions are provided for this purpose. In order to connect torepparttar 105599 MySQL server,repparttar 105600 server name/address; a username; and a valid password is required. Once a connection is successful,repparttar 105601 database needs to be specified.

The following 2 code excerpts illustrate how to performrepparttar 105602 server connection and database selection: @mysql_connect("[servername]", "[username]", "[password]") or die("Cannot connect to DB!"); @mysql_select_db("[databasename]") or die("Cannot select DB!");

XML Promises and challenges

Written by Ror Sabo

XML Born

XML (Extensible Markup Language) 1.0 standard was published February 10, 1998. XML was born fromrepparttar shortcomings of SGML [Structured Generalized Markup Language] which

was hugely complex, massively flexible and just plain hard to work with for many developers. XML has taken off because it has allrepparttar 105567 best of SGML without many ofrepparttar 105568 weakness.

XML Goal

XML took us beyond mere presentation of information and intorepparttar 105569 realm of representation

of information. This content is not just a mass of data to be rendered solely for viewing

on a web browser. Nowrepparttar 105570 content could be structured andrepparttar 105571 meaning attached to this

structure could be transmitted as well.

HTML's difficulties: 1- HTML does not reveal anything aboutrepparttar 105572 information to which HTML tags are applied.

HTML tag names don't describe what content is, they only imply how content appears.

For examplerepparttar 105573 html tag "Microsoft" appears on a web browser but HTML can not

tell is it a computer corporation? A Software? A Brand name?

2- Web applications relied too much on scripts atrepparttar 105574 server to processrepparttar 105575 data.

This makesrepparttar 105576 web slow and contributes to internet traffic.

3- You can't add new tags to HTML Language that are meaningful and useful.

4- HTML is a presentation technology only.

XML Success The Java technology, enables browsers to function as generalized application platforms. The result is True platform independence. XML provides information rich in metadata specified

in a standard format, XML and Java technology make it possible for more of an application's

work to be processed at a client side. This contrasts withrepparttar 105577 tendency of HTML pages to rely

on a script back atrepparttar 105578 server. With XML and Java technology, more client-based application

processing could reduce network and internet traffic, makingrepparttar 105579 web faster.

XML challenges Converting any information from a display format such as HTML, RTF, MIF, or PostScript to a

structured format like XML will require that you understand what your information really

contains. This requires a document analysis andrepparttar 105580 determination of information semantics on which different parts of your enterprise rely. Many enterprises in different business sectors

have established industry standard information models that can be expressed in XML and, more

importantly, can be shared.

Oncerepparttar 105581 relevant information models and their expressions in XML are constructed,repparttar 105582 effort to convert existing information intorepparttar 105583 XML format can proceed. It may or may not be painful,

depending onrepparttar 105584 condition ofrepparttar 105585 existing documents. These efforts can be done in house, or they

can be completed withrepparttar 105586 help of qualified consultants.

XML Resources: Easy XML is a simple XML editor that aids inrepparttar 105587 rapid building of XML applications. Microsoft XML for SQL Web allows you to query database tables and receiverepparttar 105588 results as an XML document.

Microsoft XML Notepad is a simple HTML prototyping application for building and editing small sets of XML-based data.

Cont'd on page 2 ==> © 2005
Terms of Use