Download What is a PHP File?

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Extensible Storage Engine wikipedia , lookup

SQL wikipedia , lookup

Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Oracle Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Team Foundation Server wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Database model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Transcript
ITX2000
Remote hosts and web servers
Week 2 – MySQL – database -- PHP
Prof. Xiaohong (Sharon) Gao
Room: T125
Ext: 12252
Email: [email protected]
What is MySQL









MySQL is a database system used on the web
MySQL is a database system that runs on a server
MySQL is ideal for both small and large applications
MySQL is very fast, reliable, and easy to use
MySQL supports standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
MySQL is developed, distributed, and supported by Oracle Corporation
MySQL is named after co-founder Monty Widenius's daughter: My
What is PhP




PHP is an acronym for "PHP Hypertext Preprocessor"
PHP is a widely-used, open source scripting language
PHP scripts are executed on the server
PHP costs nothing, it is free to download and use
What is a PHP File?
 PHP files can contain text, HTML, CSS, JavaScript, and PHP code
 PHP code are executed on the server, and the result is returned to the
browser as plain HTML
 PHP files have extension ".php”
What Can PHP Do?
 PHP can generate dynamic page content
 PHP can create, open, read, write, delete, and close files on the server
 PHP can collect form data
 PHP can send and receive cookies
 PHP can add, delete, modify data in your database
 PHP can restrict users to access some pages on your website
 PHP can encrypt data
Introduction – Basic Architecture
• At the most basic level, the Web works off of a
client/server architecture.
• That means that both a central server and a client
application are responsible for some amount of
processing.
• E.g., http://image.mdx.ac.uk/time/demo.php
From Jay Greenspan and Brad Bulger “MySQL/PHP Database Applications”, M&T Books,
New York, 2001.
The client

The applications you can develop with MySQL and PHP make
use of a single client: the Web browser.

This is not the only possibility for Internet-based applications.

For very sophisticated applications that require more clientside processing or that need to maintain state a Java applet
may be necessary.

But unless you’re coding something like a real-time chat
program, client-side Java is completely unnecessary.
Client – web browser languages
• Primary language –HTML (hypertext markup language).
• HTML provides a set of tags that describe how a Web page should look
• .
• Most browsers will accept more than HTML.
• There are all kinds of plug-ins, including RealPlayer, Flash, and
Shockwave, JavaScript, XML.
• This module will take lowest-common-denominator approach.
The server
• Almost all of the work of Web applications takes place on the server.
• A specific application, called a Web server, will be responsible for
communicating with the browser.
• A relational database server stores whatever information the
application requires.
• Finally, you need a language to broker requests between the Web
server and the database server.
• It will also be used to perform programmatic tasks on the information
that comes to and from the Web server.
• Figure I-1 represents this system.
You can’t see!
You are here!
Open source
• PHP and MySQL belong to a class of software known as open source.
• This means that the source code to the heart of their applications is available
to anyone who wants to see it.
• In the case of PHP, coders all over the world participate in the development
of the language.
• Almost all PHP/MySQL applications are running off of some version of Unix,
whether it be Linux, BSD, Irix, Solaris, HP-UX, or one of the other flavors.
• For that reason, the applications in this book will work with Unix.
• PHP – Personal Home Page or Personal Hypertext Page.
Apache sever
• Works best on Unix systems but also runs on Windows.
• Fast and stable
• Less graphic tools
Middleware
• PHP belongs to a class of languages known as middleware.
• These languages work closely with the Web server to




interpret the requests made from the WWW,
process these requests,
interact with other programs on the server to fulfil the requests,
and then indicate to the Web server exactly what to serve to the client’s
browser.
Relational databases
• Relational Database Management Systems (RDBMSs) provide a way to store and
access complex information.
• They predate the Web, Linux, and Windows.
• All of the major databases make use of the Structured Query Language (SQL).
• Some of the more popular commercial RDBMSs are Oracle, Sybase, Informix,
Microsoft’s SQL Server, and IBM’s db2.
• MySQL is open-source relational databases.
Why PHP (1)
• Fast – written in C but simpler.
• Easy – Syntax is believed to be superior to ASP and JSP.
• Easy to learn than Perl – a shell C-like language.
• Cross-platform
• Accesses everything – IMAP (Internet Message Access Protocol) Mail server,
Oracle, Informix, DB2, XML parser, WDDX (Web Distributed Data eXchange)
function, etc..
• Constantly being improved – part of open source development.
• Fully supported all over the world.
• FREE.
Why PHP (2) –other langugaes
• JSP – JavaServer Pages -- create dynamically generated web
pages based on HTML, XML.
• JSP is similar to PHP, but it uses the Java programming language.
• In Windows environment (changeable whenever Windows OS are
updated):
• ASP – Microsoft’s Active Server Pages
• IIS – Internet information Services
Why MySQL (1)?






Not everyone’s choice – e.g., bank (savings +
loan + …).
But for most web applications.
Cost-effective (Oracle/Informix, $30,000-$100,000)
Quick and powerful
Improving constantly
Fast, multi-threaded, multi-user, and robust
SQL.
Why MySQL (2) – technical features











Written in C and C++.
Works on many different platforms.
Uses GNU Automake, Autoconf, and Libtool for portability.
APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and
Tcl.
Fully multi-threaded using kernel threads -- can easily use
multiple CPUs if available.
Transactional and non-transactional storage engines.
Very fast B-tree disk tables (MyISAM) with index
compression.
Relatively easy to add another storage engine.
A very fast thread-based memory allocation system.
Available as client/server or embedded (linked) version.
MySQL Version 3.22 had a 4 GB (4 gigabyte) limit on table
size.
Brief history of MySQL
A database management system.
 A relational db.
 Open source
 MySQL Database server – fast, reliable,
easy to use.

Tools
Text editor – Notepad, ConTEXT,
 Xampp – Apache, MySQL, PHP
 LAMP – Linux, Appache, MySQL, PHP
 Linux – Ubuntu (free + Windows)

Basic UNIX commands
Start ‘Command Prompt’ – or type ‘cmd’ from ‘search window’
 cd c:\xampp – change to directory ‘c:\xampp’
 dir – list all the contents of current folder

Start Xampp
1)
2)
In the folder c:\xampp, double click ‘xamppcontrol.exe’ at
Click ‘Start’ for both ‘Apache’ and ‘MySQL’.
Start MySQL
1)
2)
3)
Start ‘Command Prompt’
cd c:\xampp\mysql\bin
mysql (or ‘mysql –u root’ (no password for now))
MySQL
mysql> show databases; (list databases that have been in the system.)
MySQL (2)
mysql> use test; (use database ‘test’)
Query OK, 1 row affected (0.00 sec)
mysql> show tables;
mysql> mysql> CREATE TABLE y2k (date DATE,
-> date_time DATETIME,
-> time_stamp TIMESTAMP);
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO y2k VALUES
-> ("1998-12-31","1998-12-31 23:59:59",19981231235959),
-> ("1999-01-01","1999-01-01 00:00:00",19990101000000),
-> ("1999-09-09","1999-09-09 23:59:59",19990909235959);
Query OK, 13 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql>
MySQL (3)
mysql> SLECT * from y2k;
More information

http://www.mysql.com/
Summary



Apache
MySQL
PHP