PHP Archive
-
Convert Database Date to Something More ‘User Friendly’
Posted on 12th Nov 2011 | No Comments// // Convert database date to something more user friendly // function userFriendlyDbDate($date){ $time = strtotime($date); return date('d/m/Y H:i', $time); } -
PHP Email Validation
Posted on 11th Nov 2011 | No CommentsEmail validation is something that is needed in a variety of situations, but I’ve always struggled to find a good one…. Well, here are 2! The first is something I... -
PHP Get Defined Vars
Posted on 12th Sep 2011 | No CommentsEver wanted to see the variables in a page? Warning!! It’ll show all of them…. <?php print_r(get_defined_vars()); ?> -
FW: PHP Logout
Posted on 9th Sep 2011 | No CommentsA good logout script is needed in most applications, and here’s the one I use. I have this script in a ‘config’ file that I call at the beginning of... -
SELECT inside a SELECT
Posted on 27th Jul 2011 | 1 CommentI often forget the exact syntax of things like this… So here’s an example… $query1 = 'SELECT * FROM `'.$dbName.'`.`users` WHERE email NOT IN (SELECT email FROM `'.$setupDBName.'`.`users`)'; -
#1054 – Unknown column in ‘where clause’
Posted on 6th Jul 2011 | No CommentsThe following SQL query causes an error SELECT vote_vo_ip, COUNT(*) as times FROM `vote` LEFT OUTER JOIN `voter` ON vote.vote_vo_id = voter.vo_id WHERE vote_co_id = 2 AND times > 1... -
Warning: Cannot modify header information – headers already sent by
Posted on 4th Jul 2011 | No CommentsIf you get a PHP error ‘Warning: Cannot modify header information – headers already sent by‘ it’s normally down to whitespace before or after the PHP start or stop tags.... -
Export to CSV file
Posted on 6th Jun 2011 | No CommentsThis is something you’re likely to do several times in several different scenarios. The common one for me is generating reports from a database. I tend to build a $_SESSION... -
Another escape data function
Posted on 5th May 2011 | No CommentsAs the title says // create a function called for escaping data function escape_data($data){ $data = ereg_replace("[^A-Za-z0-9]", "",$data); $data = str_replace('\\','',$data); $data = strtolower($data); $data = mysql_escape_string(trim($data)); return $data; } -
session_name()
Posted on 4th May 2011 | No CommentsIf you are wanting to use different more than one session on the same domain, (i.e. if you have several versions of the same login system in different folders or...







![Another escape data function As the title says // create a function called for escaping data function escape_data($data){ $data = ereg_replace("[^A-Za-z0-9]", "",$data); $data = str_replace('\\','',$data); $data = strtolower($data); $data = mysql_escape_string(trim($data)); return $data; }](http://www.jonmoore.co.uk/wp-content/uploads/2011/05/Deserts-115x115.jpg)
