Jump to content

Posting to DB


mcmuney

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

Archived

This topic is now archived and is closed to further replies.

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