Archive for April, 2009
DOCUMENT_ROOT trailing slash issues?
Posted by admin in Web design & development on April 28, 2009
Do you have a web server and a development server rendering different versions of the $_SERVER['DOCUMENT_ROOT'] superglobal?
Mmm, me too. I’d have pulled my hair out if I had any. Made me feel rather defeated after thinking I’d fixed things so that one DB connect call would work on two+ servers. Fancy that – PHP behaving unpredictably – anybody would think I was playingworking very hard with CSS.
[
I had finally got round to using substr to trim the public_htmlpart off a DocumentRoot path to get me an absolutely relative link to a safe place...
ie (substr($_SERVER['DOCUMENT_ROOT'], 0, -12). )
ie keeping the DB connect information out of the public view
]
Anyway for how to fix the trailing slash problem you should point your google at the New Zealand PHP advocates or crib directly from here:
$_SERVER['DOCUMENT_ROOT'] .=
(substr($_SERVER['DOCUMENT_ROOT'],-1)=='/')?'':'/';
We *heart* Nathan Kennedy
[MAMP stack] OpenGoo install in Mac OS X 10.5
Posted by admin in Web design & development on April 21, 2009
DON’T READ THIS! READ THIS.
Or How to setup a MAMP Stack on… Mac OS X: a proper write up.
Please disregard the gubbins on this post…
[OK - this was going to be a simple step-by-step account of how to install a particular project management system on a Mac OS X box. That particular project stalled but I learnt a few things about how to get a [M]AMP stack setup to the point a which I can continue… ]
Need a project management package. So far requirements and research lead to Open Goo.
- Download package from OpenGoo.
- Create a MySQL database for it.
- Download and instal PHP My Admin. Nice documentation.
-
- [unstuff it and put the folder into ~/Sites/ , for example]
- virtualhost it
- setup config.inc.php with blowfish key
- fix socket error (?)
- http://dev.mysql.com/doc/refman/5.0/en/mac-os-x-installation.html: edit (with TextWrangler of course) /etc/php.ini so that ”mysql.default_socket = /tmp/mysql.sock”
- Fix mcrypt error: “Cannot load mcrypt extension. Please check your PHP configuration”
- Ditch the default OS X PHP install in favour of Marc Liyanage’s packaged instal of PHP for Mac OS X
- If already set up the Apple version of PHP – make sure it’s disabled: ”
LoadModule php5_module“ in/private/etc/apache2/httpd.confshoul commented out - Download and run Marc’s installer from the link above. RTFM mind – but it’s a cinch. The new PHP files will now be in
/usr/local/php5. - Also ditch any previously installed MySQL
- sudo rm /usr/local/mysql
- sudo rm -rf /usr/local/mysql*
- sudo rm -rf /Library/StartupItems/MySQLCOM
- sudo rm -rf /Library/PreferencePanes/My*
- edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
- sudo rm -rf /Library/Receipts/mysql*
- sudo rm -rf /Library/Receipts/MySQL*
- If already set up the Apple version of PHP – make sure it’s disabled: ”
- install to match the PHP package to MySQL 5.0.77
- Create a privileged MySQL user. (Any user may log in without a password to get an anonymous session: “No Privileges”. Mac OS X user account – or _mysql. At this stage log in without a password.)
- Ye-har! Who’d of guessed… Apple’s MySQL documentation was where to find simple instructions for how to give the MySQL root user a password – and hence succeed to log inwith privileges. Terminal command:
/usr/local/mysql/bin/mysqladmin -u root password sniggle. Where sniggle is your choice for a secure password. - For each DB user you should add that user with an MySQL query:
CREATE USER 'user1'@'localhost' IDENTIFIED BY'pass1';
jQuery in anger
Posted by admin in Web design & development on April 17, 2009
[notes to self]
Shadowbox
Tooltip
highlightFade
http://jquery.offput.ca/highlightFade/old.php
jquery.validate.js
Lovely, lightweight carousel:
http://www.gmarwaha.com/jquery/jcarousellite/
http://www.noupe.com/jquery/50-amazing-jquery-examples-part1.html
http://www.jasonbradbury.com/
Google analytics
Posted by admin in Analytics, Web design & development on April 15, 2009
- Interpret your Data: Learn how to interpret your data into meaningful insights with our video tutorial.
Tag your links [esp for tracking non www links in email campaigns etc] with the URL Builder
Go to the Conversion University
Track non page events like PDF downloads, video views, clicks etc with the pageTracker
<a href="/brochure.pdf" onClick="javascript: pageTracker._trackPageview('/virtual/path/you/want/to/use/brochure.pdf'); ">Link juice</a>
Aside
WordPress note: in a block of <code> an apostrophe after a backslash needs to be added as an HTML entity: '. Strange? I think so.
Tiny URL?
Posted by admin in Web design & development on April 14, 2009
Zeldman’s just posted about the current mini-storm about URL shortening services…
I love his understated way. While the debate about these services – and, as an adjunct, feed scraping, we should look to our webdev monkey skills to roll our own solutions. He, yer Zeldman, doesn’t state as much in B&W but his example shows his own tiny URL. How? The simple redirect.
Whether or not this is done with a mod_rewrite rule or by any means necessary [dreams of CMS modules in my mind] – the fact is that it is easy a pie to make your own Tiny URLs and publish them hand in hand with the original article. Every article should have a permalink and a short version.
Of course – the redirect solution presupposes your domain isn’t www.pneumonoultramicroscopicsilicovolcanoconiosis.com…