Oct 17

Build Your Own Database-Driven Website Using PHP & MySQL

Summary of Contents of this Excerpt
Preface ..........................................................................................ix
1. Installation ............................................................................... 1
2. Getting Started with MySQL................................................ 29
3. Getting Started with PHP ..................................................... 43
4. Publishing MySQL Data on the Web................................... 67
Index......................................................................................... 345
Summary of Additional Book Contents
5. Relational Database Design................................................... 85
6. A Content Management System......................................... 101
7. Content Formatting and Submission.................................. 143
8. MySQL Administration....................................................... 165
9. Advanced SQL Queries........................................................ 183
10. Binary Data........................................................................ 199
11. Cookies and Sessions in PHP............................................ 221
12. Structured PHP Programming........................................... 235
A. MySQL Syntax .................................................................... 277
B. MySQL Functions ............................................................... 301
C. MySQL Column Types ....................................................... 321
D. PHP Functions for Working with MySQL ........................

PDF download:

Kevs-php-mysql

Jul 18

PHP Tutorial From beginner to master

PHP Tutorial From beginner to master

PHP is a powerful tool for making dynamic and interactive Web pages.
PHP is the widely-used, free, and efficient alternative to competitors such
as Microsoft’s ASP.
In our PHP tutorial you will learn about PHP, and how to execute scripts
on your server

Pre-requisites
Before you continue you should have a basic understanding of the following:
•  HTML/XHTML
•  JavaScript
What is PHP?
•  PHP stands for PHP: Hypertext Preprocessor
•  PHP is a server-side scripting language, like ASP
•  PHP scripts are executed on the server
•  PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
•  PHP is an open source software
•  PHP is free to download and use
What is a PHP File?
•  PHP files can contain text, HTML tags and scripts
•  PHP files are returned to the browser as plain HTML
•  PHP files have a file extension of “.php”, “.php3″, or “.phtml”
What is MySQL?
•  MySQL is a database server
•  MySQL is ideal for both small and large applications
•  MySQL supports standard SQL
•  MySQL compiles on a number of platforms
PHP Tutorial From beginner to master

PHP is a powerful tool for making dynamic and interactive Web pages.
PHP is the widely-used, free, and efficient alternative to competitors such
as Microsoft’s ASP.
In our PHP tutorial you will learn about PHP, and how to execute scripts
on your server

Pre-requisites
Before you continue you should have a basic understanding of the following:
•  HTML/XHTML
•  JavaScript
What is PHP?
•  PHP stands for PHP: Hypertext Preprocessor
•  PHP is a server-side scripting language, like ASP
•  PHP scripts are executed on the server
•  PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
•  PHP is an open source software
•  PHP is free to download and use
What is a PHP File?
•  PHP files can contain text, HTML tags and scripts
•  PHP files are returned to the browser as plain HTML
•  PHP files have a file extension of “.php”, “.php3″, or “.phtml”
What is MySQL?
•  MySQL is a database server
•  MySQL is ideal for both small and large applications
•  MySQL supports standard SQL
•  MySQL compiles on a number of platforms

PHP_Tutorial_From_beginner_to_master

Jul 12

PHP Tutorial – Learn PHP

Overview:

If you want to learn the basics of PHP, then you’ve come to the right place. The goal of this tutorial is to
h you the basics of PHP so that you can:
•  Customize PHP scripts that you download, so that they better fit your needs.
•  Begin to understand the working model of PHP, so you may begin to design your own PHP projects.
•  Give you a solid base in PHP, so as to make you more valuable in the eyes of future employers.
PHP stands for PHP Hypertext Preprocessor.

PHP – What is it?
Taken directly from PHP’s home, PHP.net, “PHP is an HTML-embedded scripting language. Much of its
syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of
the language is to allow web developers to write dynamically generated pages quickly.”
This is generally a good definition of PHP. However, it does contain a lot of terms you may not be used to.
Another way to think of PHP is a powerful, behind the scenes scripting language that your visitors won’t see!
When someone visits your PHP webpage, your web server processes the PHP code. It then sees which
parts it needs to show to visitors(content and pictures) and hides the other stuff(file operations, math
calculations, etc.) then translates your PHP into HTML. After the translation into HTML, it sends the webpage to
your visitor’s web browser.

PDF download:

php_tizag_tutorial

Jun 28

PHP 5 Power Programming

BRUCE PERENS’ OPEN SOURCE SERIES
http://www.phptr.com/perens
◆ Java Application Development on Linux
Carl Albing and Michael Schwarz
◆ C++ GUI Programming with Qt 3
Jasmin Blanchette, Mark Summerfield
◆ Managing Linux Systems with Webmin: System Administration and
Module Development
Jamie Cameron
◆ Understanding the Linux Virtual Memory Manager
Mel Gorman
◆ Implementing CIFS: The Common Internet File System
Christopher Hertel
◆ Embedded Software Development with eCos
Anthony Massa
◆ Rapid Application Development with Mozilla
Nigel McFarlane
◆ The Linux Development Platform: Configuring, Using, and Maintaining a
Complete Programming Environment
Rafeeq Ur Rehman, Christopher Paul
◆ Intrusion Detection with SNORT: Advanced IDS Techniques Using SNORT,
Apache, MySQL, PHP, and ACID
Rafeeq Ur Rehman
◆ The Official Samba-3 HOWTO and Reference Guide
 John H. Terpstra, Jelmer R. Vernooij, Editors
◆ Samba-3 by Example: Practical Exercises to Successful Deployment
John H. Terpstra

The authors and publisher have taken care in the preparation of this book, but make no expressed or implied
warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for inciden-
tal or consequential damages in connection with or arising out of the use of the information or programs con-
tained herein.
Publisher: John Wait
Editor in Chief: Don O’Hagan
Acquisitions Editor: Mark L. Taub
Editorial Assistant: Noreen Regina
Development Editor:Janet Valade
Marketing Manager: Robin O’Brien
Cover Designer: Nina Scuderi
Managing Editor: Gina Kanouse
Senior Project Editor: Kristy Hart
Copy Editor: Specialized Composition
Indexer: Lisa Stumpf
Senior Compositor: Gloria Schurick
Manufacturing Buyer: Dan Uhrig
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special
sales, which may include electronic versions and/or custom covers and content particular to your business,
training goals, marketing focus, and branding interests. For more information, please contact:
U. S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside the U. S., please contact:
International Sales
international@pearsoned.com
Visit us on the Web: www.phptr.com
Library of Congress Cataloging-in-Publication Data:
2004107331
Copyright © 2005 Pearson Education, Inc.
This material may be distrubuted only subject to the terms and conditions set forth in the Open Publication
License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/).
Pearson Education, Inc.
One Lake Street
Upper Saddle River, NJ 07458
Every effort was made to contact and credit all copyright holders. Use of material without proper credit
is unintentional.
ISBN 0-131-47149-X
Text printed in the United States on recycled paper at Phoenix in Hagerstown, Maryland.
First printing, [October 2004]

PDF download

Jun 23

PHP – Advanced Tutorial

PHP – Advanced Tutorial
Gulev
cember 6, 2002. Veracruz, Mexico
smus Lerdorf <rasmus@php.net>
http://lerdorf.com/veracruz.pdf

o PHP-MyS


o Cookie Ha
o Dynamic I
o PDF
o Flash
o Sessions
o Security
o Tips & Tr
o Optimizat
o Latest Dev


o Future

 

Check your PHP Setup for MySQL support
<? phpinfo() ?>
If not enabled
 Very rare since a MySQL client library is distributed with PHP and built into PHP
However, it is possible to build PHP without MySQL support.  Some possible fixes:
apt-get install php-mysql
rpm -Uvh php-mysql-4.2.2-1.i386.rpm
 
./configure –with-mysql=shared,/usr
cp modules/mysql.so /usr/local/lib/php
extension_dir=/usr/local/lib/php
extension=mysql.so

PDF download: http://download.phpfly.net/201106/PHP – Advanced Tutorial.pdf

Jun 03

PHP_My_SQL_Tutorial (PDF)

Overview
Open source has brought a lot more than Linux to the computing world. It has also given us PHP and
MySQL. According to Graeme, PHP and MySQL are the world’s best combination for creating data-driven
sites. In the first installment of this three-lesson tutorial, our Kiwi guide covers everything you need to
know to begin developing database hubs. He gives instructions for installation on both Unix and Windows,
and then goes on to show some simple scripts that will insert information into a database and display that
data on a Web page.
Lesson 2 covers more PHP/MySQL goodies than you could probably imagine. Graeme starts by showing
while loops, then talks about the ever-useful if-else statement. But this information alone means little if
you don’t continue and see how PHP can be used with HTML forms. By the time you’ve polished off this
lesson, you’ll be able to add, edit, and remove information from your database.
In Lesson 3, Graeme shows some of the secrets that will turn your simple data-driven site into a useful
application. As he covers validation, he’ll show how to prevent users from leaving key form fields blank and
how to make sure numeric files don’t contain letters. He’ll also teach you how PHP handles includes and
functions. Plus you’ll see how these two features, when deployed together, can make the coder’s life much
easier. Graeme winds it all up with some tearful parting words and a bit of advice for the aspiring
PHP/MySQL coder.
Other PHP articles on Webmonkey:
Site Navigation with PHP
Image Creation with PHP
Threaded Discussion with PHP/MySQL

movement, Linux.
Having a massively complex RDBMS (relational database management system) is all well and good if you
know what to do with it. But perhaps you are just getting into the world of databases. You’ve read Jay’s
article and you want to put up your own data-driven Web site. But you find you don’t have the resources
or desire for an ASP server or some pricey database. You want something free, and you want it to work
with Unix.
Enter PHP and MySQL. These two make up what must be the best combination for data-driven Web sites
on the planet. You needn’t take my word for it. An unofficial Netcraft survey shows that PHP usage has
jumped from 7,500 hosts in June 1998 to 410,000 in March 1999. That’s not bad. The combination was also
awarded Database of the Year at Webcon98, where it received a lovely tiara.
MySQL is a small, compact database server ideal for small – and not so small – applications. In addition to
supporting standard SQL (ANSI), it compiles on a number of platforms and has multithreading abilities on
Unix servers, which make for great performance. For non-Unix people, MySQL can be run as a service on
Windows NT and as a normal process in Windows 95/98 machines.
PHP is a server-side scripting language. If you’ve seen ASP, you’ll be familiar with embedding code within an
HTML page. Like ASP, PHP script is processed by the Web server. After the server plays with the PHP code,
it returns plain old HTML back to the browser. This kind of interaction allows for some pretty complex
operations.
In addition to being free (MySQL does have some licensing restrictions though), the PHP-MySQL
combination is also cross-platform, which means you can develop in Windows and serve on a Unix platform.
Also, PHP can be run as an external CGI process, a stand-alone script interpreter, or an embedded Apache
module.
If you’re interested, PHP also supports a massive number of databases, including Informix, Oracle, Sybase,
Solid, and PostgreSQL – as well as the ubiquitous ODBC.
PHP supports a host of other features right at the technological edge of Internet development. These
include authentication, XML, dynamic image creation, WDDX, shared memory support, and dynamic PDF
document creation to name but a few. If that’s not enough, PHP is easy to extend, so you can roll your
own solution if you’re programming savvy.
Finally, since both efforts are collaborative in nature, there’s always plenty of support from documentation
and mailing lists. Bugs are fixed rapidly, and requests for features are always heard, evaluated, and if
feasible, implemented.
Enough talk! Let’s go over what we’re going to cover in this tutorial.
Lesson 1 is going to cover the installation of these products on both Unix and Windows systems. If you
don’t need to worry about that (you’re working on your ISP’s machine, perhaps), jump right to the first
example scripts, where the magic starts.
In Lesson 2 we’ll look at some more complex scripting goodies, including looping, form input, and sending
data from and to the database.
Lesson 3 will cover validation and techniques for making your PHP scripts smart and clean.
Let’s roll.

Click here to download

May 28

php for dynamic web pages

 

CONTENTS
WHY USE PHP? 1
USING PHP ON APACHE AND UNIX 2
The php Extension 2
PHP CODE 3
Functions 3
Containers 3
PHP With Forms 4
POST and GET 5
Conditional HTML 6
PHP With E-Mail 8
A Note About Email 9
PHP With Files 9
Error Reporting 11
Write Access 11
Arrays 12
Accessing Array Data 13
Don’t Trust Anyone Outside 14
Sorting Arrays 15
Visitor Sessions 15
Requiring Cookies 17
Sessions and Security 17
The Program So Far 17
Creating Images On the Fly 18
Creating Your Own Functions 20
Optional Arguments 22
WORKING WITH MYSQL 24
Create the table 24
Create the Database 24
Create the Username and Password 24
Create the Table 24
Store the data 25
Display the data 26
CURLY BRACKETS 28
GNU FREE DOCUMENTATION LICENSE 29
0. Preamble 29
1. Applicability and Definitions 29
2. Verbatim Copying 30
3. Copying in Quantity 30
4. Modifications 31
5. Combining Documents 32
6. Collections of Documents 32
7. Aggregation With Independent Works 32
8. Translation 32
9. Termination 33
10. Future Revisions of this License 33
PHP: HYPERTEXT PROCESSOR 34

34
WHY USE PHP?
If you need to embed dynamic text into static text, you’ll find PHP extremely useful. It was
designed for this, and it excels at it. PHP is also very useful for integrating web pages with
databases.
The PHP scripting language resembles JavaScript, Java, and Perl, These languages all share a
common ancestor, the C programming language.
PHP is most different from JavaScript and Java. PHP is a server-side scripting language. All of
the “work” is done on the server. JavaScript (and Java) generally run on the client. They have
little access to the information that the server has, and mediated access to information on the
client. They can do lots of things on the client that PHP cannot. PHP has full access to the
information that the server has, and very little access to information that the client has. In fact, it
only has information that the client tells the server and that the server passes on to PHP. Because
it is on the server, however, PHP cannot be modified by the client. While you cannot necessarily
trust the information that the client gives to PHP, you can trust that your PHP is doing what you
told it to do. Because PHP is on the server end, your PHP scripts can affect your server—such as
by keeping an activity log or updating a database.
PHP and Perl often work side-by-side. These are both server-side. Where PHP excels at
embedding dynamic content, Perl excels at modifying (or “filtering”) streams of text. PHP excels
at putting things into documents, and Perl excels at finding things in documents. After you have
learned PHP, you may well find Perl useful for many tasks, especially for command-line tasks.
PHP has an advantage over Perl on most web sites because PHP is usually loaded as part of the
web server. When scripting languages “run”, the system has to first load the “interpreter” and
then “compile” the language into code that the machine can understand. When you tell PHP to
echo the current time to the web page, the computer needs to have your command translated into
numbers that it can understand. Because the PHP interpreter is already loaded as part of the web
server’s software, it is always running. This cuts out half of that process. The interpreter is
already loaded, and it can go directly to compiling the language into code. When web servers see
a request to run a Perl script, they usually have to first load the Perl interpreter. This happens
very quickly, but when there are thousands or tens of thousands of requests coming every
second, every “very quickly” can add up.
C programs are “pre-compiled”. They cut out both steps in that process: no interpreter is needed
because the program is already compiled into code the machine understands. Because of this,
however, C programs must be compiled every time you switch to a new machine. If you move to
a different host, you will usually have to recompile your C programs. Sometimes you’ll even
have to recompile your C programs when your ISP upgrades their server’s system software. And
many ISPs do not provide you with a C compiler. You’ll find that PHP is more “portable” than C
in this respect: if it works on one server, it will usually work on any other server that has it. Most
ISPs that provide server-side scripting provide PHP.

Download PDF