When I insert "<b>dog</b>" into database using php, it inserts empty string.

How to fix it?

thnx in advance

ok... actually I knew that it is html entity, but the problem is how to save such converted string in database?

Say user makes new post and the post is "<b>dog</b>", so my script as usual is gonna save it in db, but it saves "".

i tried this query , is working for me:

insert into  `test` values('<b>dog</b>');

or else post your query.

when i do it directly with phpMyAdmin or console, the insertion is ok, however when via php it inserts nothing...

ya, then please post post your query,
it may be because of quotes in your query.

this code works for me:

echo $q="insert into test values('$str')";

I think I've found the problem but haven't found the solution yet: problem comes from the root - $_POST. If text sent from client is "&lt;b&gt;dog&lt;/b&gt;", then $_POST is empty, that's why php was inserting empty string. But if normal text is sent from client everything goes ok...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.