0

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

How to fix it?

thnx in advance

2
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by Acute
0

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

Edited by Acute: n/a

0

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 "".

0

i tried this query , is working for me:

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

or else post your query.

Edited by Shanti C: n/a

0

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

Edited by Acute: n/a

0

this code works for me:

<?php 
$str='&lt;b&gt;dog&lt;/b&gt;';
$str=htmlentities($str);
echo $q="insert into test values('$str')";
?>
0

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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.