Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP echo() MySQL result containing <> characters?

I am retrieving data from my SQL database...

data exactly as it is in the DB = (21:48:26) <username> some text here. is it ok?

when i try and echo $row['log']."<br>";

it displays it as = (21:48:26) some text here. is it ok?

i assume this is due to the <> brackets making it think its an HTML opener... would this be the case? and if so how would one echo a string that contains HTML?

like image 693
medoix Avatar asked Sep 04 '26 05:09

medoix


1 Answers

Use htmlspecialchars() to translate HTML control characters into their entities:

echo htmlspecialchars($row['log'])."<br>";
like image 150
Pekka Avatar answered Sep 06 '26 17:09

Pekka