Jump to content

Recommended Posts

No, I want to input an image source in a textarea form, which saves the text in the DB and displayed on a separate page. But on that page, I want it to display the image, instead of displaying the source. For example, if I input <img src="abc.jpg">, I want it to display the image where the result is displayed. But currently, it just shows "<img src="abc.jpg"> and doesn't show the html as an image.

Link to comment
https://forums.phpfreaks.com/topic/69310-posting-to-db/#findComment-348276
Share on other sites

You're not getting it, here's my code:

 

$sql_comm="INSERT INTO `sc_postcomment_member` ( `scm_mem_id`, `comment`, `post_date`, `comm_from`) VALUES ('$scm_mem_id', '$txt_comment', UNIX_TIMESTAMP(), '$social_mem_id')"; 

 

Where "$txt_comment" is what I type in the textarea of the form.

 

But when I input <img src="abc.jpg" for example, the DB writes <img src=""> BUT I want it to write <img src="abc.jpg"> instead.

 

You see, the script is converting < into < and I don't want it to.

Link to comment
https://forums.phpfreaks.com/topic/69310-posting-to-db/#findComment-348281
Share on other sites

link

 

http://uk.php.net/manual/el/function.htmlentities.php

 

<?php

$str = "A 'quote' is <b>bold</b>";

 

// Outputs: A 'quote' is <b>bold</b>

echo htmlentities($str);

 

// Outputs: A 'quote' is <b>bold</b>

echo htmlentities($str, ENT_QUOTES);

?>

 

link

http://uk.php.net/manual/el/function.html-entity-decode.php

<?php

$orig = "I'll \"walk\" the <b>dog</b> now";

 

$a = htmlentities($orig);

 

$b = html_entity_decode($a);

 

echo $a; // I'll "walk" the <b>dog</b> now

 

echo $b; // I'll "walk" the <b>dog</b> now

 

 

// For users prior to PHP 4.3.0 you may do this:

function unhtmlentities ($string)

{

   $trans_tbl = get_html_translation_table (HTML_ENTITIES);

   $trans_tbl = array_flip ($trans_tbl);

   return strtr ($string, $trans_tbl);

}

 

$c = unhtmlentities($a);

 

echo $c; // I'll "walk" the <b>dog</b> now

 

?>

 

 

lookup stripslases and addslases and mysql_escape_string

 

Link to comment
https://forums.phpfreaks.com/topic/69310-posting-to-db/#findComment-348291
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.