+ Post New Thread
Results 1 to 11 of 11
Web Development Thread, PHP Characters in Coding and Web Development; Ive got a table setup in MySQL that will hold some textdata one of the columns is setup as LONGTEXT. ...
  1. #1

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20

    PHP Characters

    Ive got a table setup in MySQL that will hold some textdata one of the columns is setup as LONGTEXT. And the collation set to utf8_unicode. Im trying to insert characters such as the ones on the screenshot below, it displays fine in phpmyadmin but on a webpage where it pulls the text from the db the characters are displayed as question marks.

    The screenshot first is what it shows as in phpmyadmin which is correct, the second screenshot is the one from my page which is incorrect, and the third screenshot is the original

    P.S. Excuse the random piece of text, i just picked it because it had lots of random characters in

    Thanks
    Jack Dunn
    Attached Images Attached Images
    Last edited by Jackd; 6th February 2008 at 11:51 PM.

  2. #2

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,528
    Thank Post
    513
    Thanked 2,406 Times in 1,862 Posts
    Blog Entries
    24
    Rep Power
    822
    Are you using UTF8 on your php page?

  3. #3

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20
    I dont know, whats that mean, and how do i do it?

    Jack

  4. #4

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,528
    Thank Post
    513
    Thanked 2,406 Times in 1,862 Posts
    Blog Entries
    24
    Rep Power
    822
    You'd have to send a header for the php document such as

    Code:
    header ('Content-type: text/html; charset=utf-8');
    But obviously catered to your particular needs in terms of the content type.

    Note, header function calls have to be the first lines in your php code, so straight after the < ?php call.

  5. #5

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20
    Nope, with that it still doesnt seem to work still displaying the same as before

    Jack

  6. #6

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,528
    Thank Post
    513
    Thanked 2,406 Times in 1,862 Posts
    Blog Entries
    24
    Rep Power
    822
    If you try and export to a text file, what do you get displayed?

  7. #7

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20
    Quote Originally Posted by localzuk View Post
    If you try and export to a text file, what do you get displayed?
    Im sorry, but what do you mean by that, in phpmyadmin? How would i go around doing that?

    Ive tried exporting the table to Excel and it displays fine in there, and ive also exported it to standard SQL and the characters display fine in notepad

    Jack
    Last edited by Jackd; 7th February 2008 at 07:17 AM. Reason: More Info

  8. #8

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,528
    Thank Post
    513
    Thanked 2,406 Times in 1,862 Posts
    Blog Entries
    24
    Rep Power
    822
    No, instead of trying to output to a web page, can you isolate the calls in php to mysql and get it to output to a text file instead of displaying in an html page.

    ie. http://www.tizag.com/phpT/filewrite.php

  9. #9
    Jona's Avatar
    Join Date
    May 2007
    Location
    Cranleigh
    Posts
    467
    Thank Post
    14
    Thanked 50 Times in 48 Posts
    Rep Power
    23
    This is more of a work around than a solution but you could encode it to base64 http://uk2.php.net/manual/en/function.base64-encode.php and then decode it when you pull it out of the database http://uk2.php.net/manual/en/function.base64-decode.php

  10. Thanks to Jona from:

    Jackd (7th February 2008)

  11. #10

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20
    Quote Originally Posted by localzuk View Post
    No, instead of trying to output to a web page, can you isolate the calls in php to mysql and get it to output to a text file instead of displaying in an html page.

    ie. http://www.tizag.com/phpT/filewrite.php
    Done that and its still ?'s, ive attached the outputted file below

    Quote Originally Posted by Jona View Post
    This is more of a work around than a solution but you could encode it to base64 http://uk2.php.net/manual/en/function.base64-encode.php and then decode it when you pull it out of the database http://uk2.php.net/manual/en/function.base64-decode.php
    I'll have a look at this now and get back with the results shortly
    Attached Files Attached Files

  12. #11

    Join Date
    Jan 2007
    Location
    Durham, UK
    Posts
    328
    Thank Post
    33
    Thanked 17 Times in 12 Posts
    Rep Power
    20
    Thanks Jona, base64 encoding and decoding works fine!

    Jack

SHARE:
+ Post New Thread

Similar Threads

  1. Chinese characters in Office 2003?
    By zag in forum Windows
    Replies: 15
    Last Post: 1st October 2008, 09:09 AM
  2. Replies: 1
    Last Post: 17th December 2007, 08:30 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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