Results 1 to 2 of 2

Thread: special characters not being saved to database correctly

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default special characters not being saved to database correctly

    I recently updated the php language on my website to 5.6.27. After doing so Special Characters no longer display correctly on my website. I am not sure if this has to do with my php.ini file.

    My MySQL summary column in my article table is collated as utf8_general_ci

    When I submit an endash to the database it looks like the following:

    –

    Here is the code I am using:

    PHP Code:
    <?php
    include 'include/dbconnect.php';
    include 
    "$root/".'include/user.php';
    $query="UPDATE article SET summary='X–X' WHERE ID='300'";
    mysqli_query($conn,$query) or die ("Couldn't execute query.");
    ?>
    The include files are only for database usernames and passwords.

    When I go to phpmyadmin to look at how the endash is encoded it looks like –. When I display it on the website it looks like the endash should. When I try to edit the page and and submit the page to the database the encoded endash is then further encoded to –. Articles created before my php was updated display special characters as diamonds with a question mark in the middle: �

    See the following page: http://www.animeviews.com/article.php?ID=262

    Any ideas on how I can store special characters in my database as special characters again? Other examples of characters that are no longer stored in the database correctly include non breaking space, or the accented e in clientèle, etc.
    Last edited by james438; 09-24-2017 at 12:39 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Fixed:

    Code:
    <?php 
    include 'include/dbconnect.php';
    mysqli_query ($conn,"set character_set_results='utf8'");
    mysqli_query ($conn,"set character_set_client='utf8'");
    mysqli_query ($conn,"set collation_connection='utf8_general_ci'");
    include "$root/".'include/user.php'; 
    $query="UPDATE article SET summary='X–X' WHERE ID='300'"; 
    mysqli_query($conn,$query) or die ("Couldn't execute query."); 
    ?>
    https://stackoverflow.com/questions/...abase-with-php
    To choose the lesser of two evils is still to choose evil. My personal site

Similar Threads

  1. Resolved special characters
    By ggalan in forum HTML
    Replies: 4
    Last Post: 08-25-2011, 08:49 PM
  2. Replies: 5
    Last Post: 01-11-2011, 08:56 PM
  3. Resolved UTF-8 and special characters.
    By jlizarraga in forum HTML
    Replies: 3
    Last Post: 01-15-2009, 12:44 AM
  4. Special Characters
    By matilda in forum JavaScript
    Replies: 6
    Last Post: 02-23-2008, 04:05 PM
  5. Special characters
    By Kyle in forum HTML
    Replies: 0
    Last Post: 10-29-2006, 01:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •