Posts filed under 'PHP/MySQL Snippets'
I’m new to PHP running in Safe Mode, but since I started using Media Temple for a client I have had to take some time to understand the common workarounds. For those of you unfamiliar with PHP Safe Mode, it locks script permissions down tightly and only allows a script to execute or modify a file it “owns”. This means that many of the tasks typically run from a browser that modify the file structure of a Web site are no longer possible.
Thankfully, PHP allows users to set up a PHP as CGI folder and run the scripts from that folder with full permissions to access the site’s directory structure. Exactly why this is more secure escapes me. Larry Ullman’s forum has an interesting thread discussing exactly how to set this up.
There’s also a useful article in Media Temple’s knowledge base.
October 26th, 2006
Yesterday, I needed to select a list of albums from a database searching on a list of instruments the artists played. This worked fine as long as there were not multiple artists playing the same instrument, in which case, the album was repeated in my list for each instance of the selected instrument.
To fix the problem, I needed to select that album as DISTINCT even though my search string was repeated. I found a code snippet that I modified to achieve this on the MySQL site here:
the whole query for retrieving an array of rows with one field distinct (no repeats) is:
select *, count(FIELD) from TABLE group by FIELD having count(FIELD)>=1;
October 24th, 2006
If you ever need a failsafe way to redirect browsers with PHP, whether or not the page headers have already been sent, look no further than Jakob B.’s snippet on PHP.net.
This code snippet uses the cleanest method, the php header function, if it is available. Otherwise, it defaults to javascript. Failing that approach it uses the old meta refresh method.
August 19th, 2006
About Harvey Ramer
CSS Web design, e-commerce Web design, and internet marketing issues from the desk of Harvey A. Ramer at Design Delineations.

Harvey Recommends
Calendar
May 2008
| M |
T |
W |
T |
F |
S |
S |
| « Apr |
|
|
| | 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
|
Posts by Month
Posts by Category