Tarida George
Tarida George

Reputation: 1303

Strange echo string from MySql

In my MySQL database I have someting like "Hello <<smt>>" and I use PHP to echo this out nl2br($msg['CONTENT']); The output in index.php is:

"Hello <>"

Why's that?

And if I have in database something like "Hello <smt>" in index.php show me only "Hello". What to do?

Upvotes: 1

Views: 108

Answers (2)

echo_Me
echo_Me

Reputation: 37233

by using htmlentities() u can get your values

look demo here

Upvotes: 0

mbinette
mbinette

Reputation: 5094

nl2br only turns \n into <br/>.

string nl2br ( string $string [, bool $is_xhtml = true ] )

Returns string with <br /> or <br> inserted before all newlines (\r\n, \n\r, \n and \r).


It has nothing to do with your problem. Your problem has to do with trying to display HTML tags. The browser recognize those tags and tries to parse them (like if it were a <span>).

To use those tags as display characters, just use htmlentities.

Example

htmlentities(nl2br($msg['CONTENT']));

Upvotes: 2

Related Questions