Zend - The PHP Company




Code Gallery: woodys


Easy Display of Dollars?  

Type: code fragment
Added by: woodys
Entered: 13/09/2000
Last modified: 01/12/2000
Rating: ** (3 votes)
Views: 9885
You know those stupid little things you come accross after years in the profession, that make you say "Golly, if I'd just known that 3 or 4 years ago, it would have saved a ton of work!" This is one of them.


Fix to PHP4/MySQL problem  

Type: code fragment
Added by: woodys
Entered: 22/08/2000
Last modified: 04/12/2000
Rating: **** (5 votes)
Views: 6121
I ran one of my database front-ends that worked great in PHP3, under PHP4 and found that back-slashes started poping up like rabbits on fertility hormones. After a little research into the problem, I found out what it was: mysql_escape_string, a function not availble in PHP3 was implemented "transparently" in PHP4 and (unfortunately) was installed "backwards": It escapes the result set, which is not how string escaping was intended. The fix: I've made a fix called mysql_unescape_string. You won't find an analog of it at www.mysql.com because its a bastard function specifically for taking care of the PHP4 implementation problem. See the example section for usage of it... (Also, see the "mysql_escape_string" function in this same section for my original fix for string escaping in MySQL)


Implementing a "Members ONLY" area  

Type: code fragment
Added by: woodys
Entered: 11/09/2000
Last modified: 04/12/2000
Rating: **** (10 votes)
Views: 23353
This selection of PHP files will allow you to implement a "member's only" area in your web site, complete with recognizing re-entering members and new member form. Uses MySQL back-end.


Microsoft DAO 3.5 compliant data access to MySQL database  

Type: class library
Added by: woodys
Entered: 28/09/2000
Last modified: 04/12/2000
Rating: ***** (6 votes)
Views: 11278
What is the most common way to access data in the world today? If pressed for this answer, I would have to say it is Microsoft DAO (a.k.a. Data Access Object) whether it be with a VB, Access or VC++ front-end or with an Access or enterprise-level back-end. The greatest single group of application programmers use DAO, period. This first stab at providing the most important parts of DAO (i.e. those that are use about 90% of the time) is my hope that many ASP programmers, sickened by Microsoft's insistance that web-based programming be done with the cumbersome, twitchy, and many times over-complicated ADO (ActiveX Data Object) may turn to PHP and MySQL without having to relearn a different data access methodology. There are some important things missing in this first release. Recordset objects don't have the old "edit/update" functionality, and in this first release don't even have a findfirst/findnext method (but it is coming). But even with all the missing pieces, this release allows you to do everything you need to: query the database, execute SQL commands, traverse recordsets, object-based approaches. AND its available by including just one small file at the top of every PHP script you write. Email me with your thoughts people! I'll get to it faster if there is a need out there!


MySQL Database Backup  

Type: code fragment
Added by: woodys
Entered: 31/07/2001
Last modified: 08/12/2000
Rating: ***** (4 votes)
Views: 10581
This is a function that backs up the structure and data of a MySQL database and represents them as a large text file of SQL statements. Doesn't require special disk access permissions, it pulls everything through the connection handle itself. Output can be sent transfered via FTP (i.e. by transfering the text file) or by HTTP (i.e. by direct output to the invoking browser).


mysql date/time converters  

Type: code fragment
Added by: woodys
Entered: 13/06/2000
Last modified: 09/12/2000
Rating: ***** (10 votes)
Views: 20529
New and Improved! New function mysql_cvdate allows you to take a form-entered date value and express it in mysql's SQL date format. Also includes some real-life functions you can call to perform common date/time conversions between MySQL datetime format, MySQL timestamp format and UNIX timestamp (i.e. seconds after epoch) with "human" output. Time left function perfect for auction scripts, or where you need output of the difference between two supplied times.


mysql date/time converters, part II  

Type: code fragment
Added by: woodys
Entered: 26/09/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 7492
Someone wanted to have a converter that took a "human" time and converted it to a MySQL timestamp. Use the function cvdate() to convert to a UNIX time stamp, then use timestamp_to_mysql() (fount in the original mysql date/time converters article) to get the MySQL timestamp value. (Also check out strtotime() for a good english to timestamp converter!)


mysql date/time converters, part II  

Type: code fragment
Added by: woodys
Entered: 26/09/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 6639
Someone wanted to have a converter that took a "human" time and converted it to a MySQL timestamp. Use the function cvdate() to convert to a UNIX time stamp, then use timestamp_to_mysql() (fount in the original mysql date/time converters article) to get the MySQL timestamp value. (Also check out strtotime() for a good english to timestamp converter!)


MySQL to Access Transfer  

Type: application
Added by: woodys
Entered: 08/08/2001
Last modified: 08/12/2000
Rating: - (fewer than 3 votes)
Views: 5150
This is the easiest way I know how to get data from a MySQL database to and Microsoft Access database. Its not automatic, but its by far the best way to move tables from MySQL to Access. A single function generates a CSV file (with Access string escaping) that can be easily downloaded and "imported" into Access.


mysql_escape_string  

Type: application
Added by: woodys
Entered: 10/07/2000
Last modified: 08/12/1999
Rating: **** (3 votes)
Views: 5158
A big hole in PHP's mysql support: the lack of mysql_escape_string function. Wondered what the easiest way of taking any zero-terminated string (i.e. one with single/double quotes, commas, special chars) and putting it in an SQL statement so it ALWAYS WORKS? Use this version of mysql_escape_string; based on the formal MySQL escape charater definition found at www.mysql.com.


Priority Mail Shipping Calculator  

Type: code fragment
Added by: woodys
Entered: 18/07/2001
Last modified: 07/12/2000
Rating: - (fewer than 3 votes)
Views: 9038
This function returns the price to send a standard Priority Mail package from one zip code to another zip code, based on weight. No USPS-issued username or password is required. Safety feature. Error repression.


Report Generation in Microsoft Access from a MYSQL database  

Type: application
Added by: woodys
Entered: 08/10/2000
Last modified: 01/12/2000
Rating: *** (3 votes)
Views: 8373
PHP is great for a lot of things, but report generation is NOT one of them (compared to Crystal Reports or other report generators). I really like Microsoft Access's report environment, but its a royal pain in the butt to tranfer data from a MySQL database to Access, especially if you need to do it multiple times (like you have to with real life reports). Here is the simplest way I know how to do it FULLY AUTOMATICALLY.




Search