Download presentation
Presentation is loading. Please wait.
Published byGeorgina Hoover Modified over 8 years ago
1
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: 12252 Email: x.gao@mdx.ac.ukx.gao@mdx.ac.uk Week 2 – MySQL – database -- PHP
2
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
3
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
4
Introduction – Basic Architecture From Jay Greenspan and Brad Bulger “MySQL/PHP Database Applications”, M&T Books, New York, 2001. 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.phphttp://image.mdx.ac.uk/time/demo.php
5
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 client- side 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.
6
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.
7
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.
8
You are here! You can’t see!
9
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.
10
Apache sever Works best on Unix systems but also runs on Windows. Fast and stable Less graphic tools
11
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.
12
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.
13
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.
14
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
15
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.
16
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.
17
Brief history of MySQL A database management system. A relational db. Open source MySQL Database server – fast, reliable, easy to use.
18
Tools Text editor – Notepad, ConTEXT, Xampp – Apache, MySQL, PHP LAMP – Linux, Appache, MySQL, PHP Linux – Ubuntu (free + Windows)
19
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
20
Start Xampp 1) In the folder c:\xampp, double click ‘xampp- control.exe’ at 2) Click ‘Start’ for both ‘Apache’ and ‘MySQL’.
21
Start MySQL 1) Start ‘Command Prompt’ 2) cd c:\xampp\mysql\bin 3) mysql (or ‘mysql –u root’ (no password for now))
22
MySQL mysql> show databases; (list databases that have been in the system.)
23
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>
24
MySQL (3) mysql> SLECT * from y2k;
25
More information http://www.mysql.com/
26
Summary Apache MySQL PHP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.