Thursday, 2 April 2015

Mysql: How to write flexible INSERT and UPDATE statements in MySQL

MySQL provides several variations on INSERT and UPDATE to allow inserting and updating exactly the desired data. These features provide a lot of power and flexibility, making MySQL significantly more capable than it otherwise might be. In this article I’ll give an overview of each feature, help you understand how to choose among them, and point out some things to watch out for.SetupI am using MySQL 4.1.15 to create my examples. I assume MyISAM tables without support for transactions, with the following sample data: create table t1 ( a int not...

Wednesday, 1 April 2015

PHP: Detect what browser your website is being accessed from using php

This is a short hack on how to figure out what OS you site is being accessed from. This is useful if you want to redirect to different versions of your site through php. <?php $iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); $iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad"); $Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android"); $webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS"); ?&g...