PHP Archive

  • // // Convert database date to something more user friendly // function userFriendlyDbDate($date){ $time = strtotime($date); return date('d/m/Y H:i', $time); }

    Convert Database Date to Something More ‘User Friendly’

    // // Convert database date to something more user friendly // function userFriendlyDbDate($date){ $time = strtotime($date); return date('d/m/Y H:i', $time); }

    Continue Reading...

  • Email 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 Email Validation

    Email 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...

    Continue Reading...

  • Ever wanted to see the variables in a page? Warning!! It’ll show all of them…. <?php print_r(get_defined_vars()); ?>

    PHP Get Defined Vars

    Ever wanted to see the variables in a page? Warning!! It’ll show all of them…. <?php print_r(get_defined_vars()); ?>

    Continue Reading...

  • A 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...

    FW: PHP Logout

    A 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...

    Continue Reading...

  • I 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`)';

    SELECT inside a SELECT

    I 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`)';

    Continue Reading...

  • The 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...

    #1054 – Unknown column in ‘where clause’

    The 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...

    Continue Reading...

  • If 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....

    Warning: Cannot modify header information – headers already sent by

    If 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....

    Continue Reading...

  • This 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...

    Export to CSV file

    This 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...

    Continue Reading...

  • 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; }

    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; }

    Continue Reading...

Page 1 of 41234