News for November 2009

[not so good] programming practice

If you were ever in a hurry to fix something on a live-page you might have gotten the idea to just do something like this:

if($_SESSION["customer_id"]==’815′)
echo “new cool design – still with errors”;
else
echo “old crummy design – completely error free”;

If you so far have not found out about the disadvantages of this approach – consider yourself lucky. Because – if($_SESSION["customer_id"]==’815′) – can easily turn into something like this when you are in a hurry: if($_SESSION["customer_id"]=’815′). And that might be a major problem. :)

Just imagine everybody ordering on your customer account. HEYYYYYY!! What a joy! So my advice is to either test on a separate development server (good girl) or to do something ugly but handy like this (baaaad, bad girl) in a config file or a file which is included on every page:

if($_SESSION["customer_id"]==’815′)
$GLOBAL["testingMode"]=1;

Then you can go like if($GLOBAL["testingMode"]==’1′) whereever you want and if you go like if($GLOBAL["testingMode"]=’1′) you have a maximum damage of the new error-ridden design molesting the customers instead of them ordering in the name of somebody they do not know.

Posted: November 26th, 2009
Categories: Programming
Tags:
Comments: No Comments.

Convert page from latin to utf-8

If you ever had the pleasure of converting a page from iso to utf-8 and had mixed encodings in your database you will appreciate this link.

http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html

Posted: November 10th, 2009
Categories: Programming
Tags:
Comments: No Comments.