Calendar.php
The following listing shows the final calendar code. Notice that the numbers at the beginning of each line are not part of the code they appear here to aid in the discussion that follows the listing. Display a calendar and allow user to move forward and backward through months via form controls. month last month displayed year last year displayed calendar TRUE if this script is calling, mini to display miniature calendar Form control POST Next Next month Form control POST Prev Previous month...
Understanding How PHP Works with Apache
Apache uses MIME types to determine how to serve up specific files. For example, look at the PHP MIME type definition in the Apache configuration file AddType application x-httpd-php .php .phtml Whenever Apache is asked to serve up a file with a .php or .phtml extension, it identifies the file as a PHP file and utilizes the appropriate module the PHP module to help serve it. In PHP's case, the module provides communication with the PHP engine. The engine executes the PHP code and directs any...
Turning Off Verbose Error Reporting
You usually want to turn off verbose error reporting in production scripts. The main reason for this has to do with security you don't want users seeing too much of the man behind the curtain. For example, PHP usually outputs something similar to the following if it fails to connect to a database Warning Access denied for user 'username localhost' Using password YES in var www html errortest.php on line 11 Warning MySQL Connection Failed Access denied for user 'username localhost' Using...
The Articles Table
The articles table is the heart of the system, storing all articles for retrieval via various utility programs. The articles table needs to store the following pieces of data An index to uniquely identify the article The publication date of the article The category to which the article is assigned A short title for the article The full text of the article A field to identify the article as a draft or a final copy The MySQL create statement for this table is as follows idx int 10 unsigned NOT...
PHP Variables
PHP denotes variables with a dollar sign. Variable names can be any length and contain numbers, letters, or underscores. Variable names must start with a letter or an underscore they cannot start with a number. Examples of valid variables include the following You can use variables to store text, integers, or floating-point values. Because PHP variables are untyped, you can store any type of data in any variable and even store multiple types of data in the variable. For example, any of the...
Working with Forms
Understanding how PHP handles form data I TML forms provide an excellent framework for receiving data from users. They provide tJ a data entry GUI, rudimentary error checking, and can be used to pass the received I data on to a script where the data can be parsed, stored, and so on. 30 Min. This session reviews HTML forms and how PHP can be used as a form handler to receive To Go and use the data from the forms. Before delving into how PHP works with forms, you should understand how HTML forms...
Calendar.php 2
The calendar script was not set up to handle appointments it was a simple display-only model. However, the changes needed to make it work with this new project are very simple. Construct a valid name value pair for inclusion in the hyperlink and surround your numeric date display with the appropriate anchor tags to make it a hyperlink. The following code snippet shows the additional code in bold. This code replaces lines 203-211 in the final calendar.php code listing in the previous session....
The Value of the Right Tools
PHP does not have its own Integrated Development Environment IDE at least not yet. However, several separate IDEs are available for PHP, including the following PHPEdit www.phpedit.biz products PHPEdit NuSphere phpED www.nusphere.com KPHPDevelop www.project9.com kphpdev Zend Studio OSee Section 9 of the PHP HOW-TO IDE tools for PHP for more information on IDEs for PHP You can use just about any editor to write your scripts. However, it pays to invest in learning and using a good...
0 Testing Queries and Functions
When encountering errors with your queries, you should usually print the offending query 10 Min. so that you can cut and paste it into the MySQL console. Typically, the error is readily To Go apparent, but you may find that you need to break the query down and troubleshoot it further, as discussed in Session 11. Once you have the query functioning in the monitor, you can return to your PHP code and emulate the fix there. An even more generic way to handle debugging around the MySQL calls is to...


