Jump to content

Timmy

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Timmy

  1. Hi there!

     

    I used to have an account on the Stevie server with the username timmy. I believe that my username was never released after the server failed. I was wondering if this username could be freed up so I can re-use it on my new account?

     

    Thanks!

  2. Hi there,

     

    I'm not staff but I think I might be able to help you. :)

     

    Database

    While it's probably better to be consistent, database collations don't really matter. Just tested that.

     

    PHP

    Let's make sure PHP is ready to display unicode characters.

     

    Tell your database connection to use utf8 after connecting:

    <?php
    
    // Establish database connection
    $db = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);
    $db->set_charset('utf8');
    
    // Catch any connection errors
    if ($db->connect_errno) {
       die('DB Error: ' . $db->connect_error);
    }

     

    Escape database data before outputting to a web page:

    <?php
    
    // Require database connection file
    require_once 'database.php';
    
    // Create escape function
    function e($string) {
       return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
    }
    
    // Getting data from database
    $data = $db->query("SELECT * FROM guestbook");
    
    // Escape and output to page
    while ($row = $data->fetch_assoc()) {
       echo e($row['message']) . '<br>';
    }

     

    HTML

    Define your charset in the head of your HTML:

    <meta charset="utf-8">

  3. This topic is a little old but I think I might be able to add a little bit more information about changing timezones.

     

    PHP

    Here's an example on how to get and change timezones. Changing the timezone affects functions related to time and date:

    <?php
    echo date_default_timezone_get(); // Get default timezone used by date/time functions
    echo date('Y-m-d H:i:s'); // Get current time
    
    date_default_timezone_set("UTC"); // Change default timezone to UTC
    echo date_default_timezone_get(); // Get default timezone used by date/time functions
    echo date('Y-m-d H:i:s'); // Get current time
    

    Will output:

    America/Los_Angeles
    2015-05-01 06:14:49
    UTC
    2015-05-01 13:14:49
    

     

    SQL

    Now, you were probably referring to the NOW() function in SQL.

     

    Get timezone used by server:

    SELECT @@system_time_zone;

    Will output:

    PDT

     

    Change timezone used by server (for current session):

    SET time_zone = '+00:00'; -- Change timezone to UTC
    SELECT NOW();
    

    Will output:

    2015-05-01 13:16:28

×
×
  • Create New...