-1

Take a look here: http://www.sw-bfs.com/index.php?siteid=t_rules&id=5

It is adding weird diamond like shapes and removing formatted text like from the original body. The database uses UTF8 and I am using nl2br in PHP to pull the record. Any suggestions on how to fix it?

EDIT:

Using this code here:

  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Seems to have fixed the weird formatting, but the website is still not showing anything in between such as that is in the text. Any thoughts on how to repair that then? I am assuming this is caused by the nl2br perhaps?

user1924218
  • 99
  • 1
  • 11
  • Your encoding is wrong, that's why it isn't printing correctly. Also, it'd be best to fix your PHP/SQL fetch code as you're prone to [SQL Injections](https://en.wikipedia.org/wiki/SQL_injection). – Darren Dec 14 '15 at 05:19
  • How do I fix the encoding? – user1924218 Dec 14 '15 at 05:26

1 Answers1

0

Try,

htmlspecialchars($data_string, ENT_QUOTES, 'UTF-8');

OR You can add in head section,

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Thanks.

Darren
  • 13,050
  • 4
  • 41
  • 79
user1544541
  • 193
  • 3
  • So this partially worked. It fixed a lot of the weird formatting that was there. However, I have text placed in between and ?> like so: and it seems to be making that invisible on the page, almost like it thinks it is a scripting language or something. Anything I can do to fix that? – user1924218 Dec 14 '15 at 14:50
  • Nevermind, I did this to the line which fixed it: nl2br(htmlspecialchars($data_string, ENT_IGNORE, 'UTF-8')) as well as adjusted the META information. Thanks for the help! PS: Yes, I know it is unwise to use Ent_ignore... But it works for now. – user1924218 Dec 14 '15 at 16:23
  • Glad to help you. Use instead of and ?> as some servers will throw error. You have to check your php.ini and set allow_url_short_tag = on in order to use and ?> – user1544541 Dec 15 '15 at 05:58