PHP and MySQL
New: Visit my "PHP Musings" blog for more on the topic of PHP, MySQL, and related (and maybe unrelated) subjects.
PHP is a general-purpose, multi-platform scripting language optimized for use with web applications. MySQL is a multi-platform relational database management system. PHP includes many functions specifically for working hand-in-hand with MySQL; and as both are open-source programs, they are very popular for use in creating interactive web applications. As such, they have become my tools of choice for web programming.
Latest News from PHP.net
PHP 5.3.2 Release Announcement (2010-03-04)
The PHP development team is proud to announce the immediate release of PHP 5.3.2. This is a maintenance release in the 5.3 series, which includes a large number of bug fixes. Security Enhancements and Fixes in PHP 5.3.2:Improved LCG entropy. (Rasmus, Samy Kamkar)Fixed safe_mode validation inside tempnam() when the directory path does not end with a /). (Martin Jansen)Fixed a possible open_basedir/safe_mode bypass in the session extension identified by Grzegorz Stachowiak. (Ilia)Key Bug Fixes in PHP 5.3.2 include:Added support for SHA-256 and SHA-512 to php's crypt.Added protection for $_SESSION from interrupt corruption and improved "session.save_path" check.Fixed bug #51059 (crypt crashes when invalid salt are given).Fixed bug #50940 Custom content-length set incorrectly in Apache sapis.Fixed bug #50847 (strip_tags() removes all tags greater then 1023 bytes long).Fixed bug #50723 (Bug in garbage collector causes crash).Fixed bug #50661 (DOMDocument::loadXML does not allow UTF-16).Fixed bug #50632 (filter_input() does not return default value if the variable does not exist).Fixed bug #50540 (Crash while running ldap_next_reference test cases).Fixed bug #49851 (http wrapper breaks on 1024 char long headers).Over 60 other bug fixes. For users upgrading from PHP 5.2 there is a migration guide available here, detailing the changes between those releases and PHP 5.3. Further information and downloads: For a full list of changes in PHP 5.3.2, see the ChangeLog. For source downloads please visit our downloads page, Windows binaries can be found on windows.php.net/download/. (more...)
PHP 5.2.13 Released! (2010-02-25)
The PHP development team would like to announce the immediate availability of PHP 5.2.13. This release focuses on improving the stability of the PHP 5.2.x branch with over 40 bug fixes, some of which are security related. All users of PHP 5.2 are encouraged to upgrade to this release. Security Enhancements and Fixes in PHP 5.2.13:Fixed safe_mode validation inside tempnam() when the directory path does not end with a /). (Martin Jansen)Fixed a possible open_basedir/safe_mode bypass in session extension identified by Grzegorz Stachowiak. (Ilia)Improved LCG entropy. (Rasmus, Samy Kamkar) Further details about the PHP 5.2.13 release can be found in the release announcement, and the full list of changes are available in the ChangeLog. (more...)
PHP 5.2.12 Released! (2009-12-17)
The PHP development team would like to announce the immediate availability of PHP 5.2.12. This release focuses on improving the stability of the PHP 5.2.x branch with over 60 bug fixes, some of which are security related. All users of PHP 5.2 are encouraged to upgrade to this release. Security Enhancements and Fixes in PHP 5.2.12:Fixed a safe_mode bypass in tempnam() identified by Grzegorz Stachowiak. (CVE-2009-3557, Rasmus)Fixed a open_basedir bypass in posix_mkfifo() identified by Grzegorz Stachowiak. (CVE-2009-3558, Rasmus)Added "max_file_uploads" INI directive, which can be set to limit the number of file uploads per-request to 20 by default, to prevent possible DOS via temporary file exhaustion, identified by Bogdan Calin. (CVE-2009-4017, Ilia)Added protection for $_SESSION from interrupt corruption and improved "session.save_path" check, identified by Stefan Esser. (CVE-2009-4143, Stas)Fixed bug #49785 (insufficient input string validation of htmlspecialchars()). (CVE-2009-4142, Moriyoshi, hello at iwamot dot com) Further details about the PHP 5.2.12 release can be found in the release announcement, and the full list of changes are available in the ChangeLog. (more...)
Articles and Scripts
The following are a few articles/scripts I've cobbled together at one point or another regarding common issues in the use of these tools:
- (Updated 2008/05/12) The code I use for my Email Me page.
- Image rotation script: uses an AJAX implementation of JavaScript and PHP to rotate through a series of images with a time delay
- Anagram Finder: a little proof-of-concept script you might find fun or interesting
- PHP5 class for parsing ini files into a data array or object.
- JavaScript-based Background and text color-picker, using PHP to create the color palettes.
- Hack for a Problem with IE Displaying HTML Content via the OBJECT Tag
- Time Difference: a function to express the difference between two date/time values in terms of years, months, weeks, days, hours, minutes, and seconds
- Lorem Ipsum text generator
- PHP Dice Rolling Program
- Login Control with PHP
- Defensive Driving with PHP
- PHP class for MySQL interface
Links
Here are a few links to on-line references and sources which I frequently use:
- PHP Manual (see the Documentation page for other languages)
- MySQL 5.0 Refernece Manual
- PHP Forum at WebDeveloper.com
- Articles and tutorials at Zend.com
Forcing a File Download
This is just a little tip I picked up at the PHPBuilder.com forum to ensure that a file is presented for downloading rather than being automatically opened by a browser.
<?php
header('Content-Length: '.$fileSize);
header('Content-Type: '.$mimeType);
header('Content-Disposition: attachment; filename="'.$fileName.'"');
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');