PHP Archive

  • Using this script in an include just helps level the playing field…. ;-) <?php if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value;...

    Check Magicquotes

    Using this script in an include just helps level the playing field…. ;-) <?php if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value;...

    Continue Reading...

  • Here’s a great little script that will back-up your database to a zipped .gz file and store it in a folder on your server…. <?php // Set Vars $dbname =...

    Backup Database with PHP

    Here’s a great little script that will back-up your database to a zipped .gz file and store it in a folder on your server…. <?php // Set Vars $dbname =...

    Continue Reading...

  • Here’s another way to connect to the databse: // Connect with username, password, etc... $link = mysqli_connect('localhost', 'userName', 'passWord'); if (!$link){ $error = 'Unable to connect to the database server.';...

    Connect To Database With mysqli_connect

    Here’s another way to connect to the databse: // Connect with username, password, etc... $link = mysqli_connect('localhost', 'userName', 'passWord'); if (!$link){ $error = 'Unable to connect to the database server.';...

    Continue Reading...

  • It’s a good idea to use $_SERVER['DOCUMENT_ROOT'] with includes as it makes life easier if moving a site onto a different development server… i.e. <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; ?>

    $_SERVER['DOCUMENT_ROOT']

    It’s a good idea to use $_SERVER['DOCUMENT_ROOT'] with includes as it makes life easier if moving a site onto a different development server… i.e. <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; ?>

    Continue Reading...

  • Used to change HTML characters into ‘safer’ versions… i.e. for use in $_GET[], SQL injection, etc… htmlspecialchars($myVariable, ENT_QUOTES, 'utf-8'); ‘&’ (ampersand) becomes ‘&’ ‘”‘ (double quote) becomes ‘"’ when ENT_NOQUOTES is...

    htmlspecialchars()

    Used to change HTML characters into ‘safer’ versions… i.e. for use in $_GET[], SQL injection, etc… htmlspecialchars($myVariable, ENT_QUOTES, 'utf-8'); ‘&’ (ampersand) becomes ‘&amp;’ ‘”‘ (double quote) becomes ‘&quot;’ when ENT_NOQUOTES is...

    Continue Reading...

  • Simple enough…. $result = mysql_query('SELECT * FROM table1'); $num_rows = mysql_num_rows($result); $num_rows returns the number of records returned by the query….

    Count Rows / Records

    Simple enough…. $result = mysql_query('SELECT * FROM table1'); $num_rows = mysql_num_rows($result); $num_rows returns the number of records returned by the query….

    Continue Reading...

  • Another splendid idea from Mark Jackson (MJ Digital). This loops through the database and replaces a certain string with another… Ideal is a site name has been changed…. Or I...

    Find and Replace text in whole MySQL database

    Another splendid idea from Mark Jackson (MJ Digital). This loops through the database and replaces a certain string with another… Ideal is a site name has been changed…. Or I...

    Continue Reading...

Page 4 of 41234