Jump to content


Photo

change html and mysql characters in text to insert it to mysql



  • Please log in to reply
5 replies to this topic

#1 aliento

aliento

    Advanced Member

  • Members
  • PipPipPip
  • 170 posts

Posted 24 March 2013 - 12:21 PM

Hello,

i want to know how can i change common sql and html characters at the submit form text boxes and textareas so i can insert them in db. 

When i enter the ' character it returns sql error also i dont want to insert html into the db.

Thank you


Logic divided only in two parts "if ... then" and "foreach ... do"

#2 aliento

aliento

    Advanced Member

  • Members
  • PipPipPip
  • 170 posts

Posted 24 March 2013 - 12:23 PM

sorry for my bad English i try the best


Logic divided only in two parts "if ... then" and "foreach ... do"

#3 PaulRyan

PaulRyan

    Hello World

  • Members
  • PipPipPip
  • 874 posts
  • LocationUK
  • Age:22

Posted 24 March 2013 - 12:31 PM

You probably need mysql_real_escape_string


My Internet Home - Dumping ground for new ideas/tips/tricks and general grievances of developing.

 

Firefox 17 - PHP 5.4 - MySQL 5 - Win7 [64-bit]

Rule for asking for help: If you don't show that you've tried to accomplish something, you don't deserve help.


#4 aliento

aliento

    Advanced Member

  • Members
  • PipPipPip
  • 170 posts

Posted 24 March 2013 - 12:36 PM

Thank you

What i put into the db i show it at html pages so how can i avoid closing an html tag like > ?


Logic divided only in two parts "if ... then" and "foreach ... do"

#5 PaulRyan

PaulRyan

    Hello World

  • Members
  • PipPipPip
  • 874 posts
  • LocationUK
  • Age:22

Posted 24 March 2013 - 12:46 PM

You want to display ">"? You use htmlentities when display the data to the user.

 

Take this for example:

<?PHP

  $HTML = '<span> THIS IS HTML </span>';
 
  echo 'Will not display ">" - '. $HTML;
 
  echo '<br> ------------------------- <br>';
 
  echo 'Will display ">" - '. htmlentities($HTML);
 
?>

My Internet Home - Dumping ground for new ideas/tips/tricks and general grievances of developing.

 

Firefox 17 - PHP 5.4 - MySQL 5 - Win7 [64-bit]

Rule for asking for help: If you don't show that you've tried to accomplish something, you don't deserve help.


#6 aliento

aliento

    Advanced Member

  • Members
  • PipPipPip
  • 170 posts

Posted 24 March 2013 - 12:47 PM   Best Answer

thank you


Logic divided only in two parts "if ... then" and "foreach ... do"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com