Can't display C/C++ code correctly after adding/saving/inserting code into mysql table
-
25-10-2019 - |
Question
code like that with < (left angle bracket)=>
#include<iostream>
#include<vector>
#include<string>
It's displayed as =>
#include
#include
#include
code after <(left angle bracket) is deleted. Why does it occur?
posts table=>
mysql> describe posts;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | | NULL | |
| title | varchar(255) | NO | | NULL | |
| body | text | YES | | NULL | |
| category_id | int(11) | NO | | NULL | |
| tags | varchar(50) | NO | | NULL | |
| mark | tinyint(4) | NO | | 1 | |
| created | datetime | YES | | NULL | |
| modified | datetime | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)
Solution
It would help if you showed your output code from your view, but you should be able to do something like this:
echo htmlentities($listposts['Post']['body']);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow