Php Classroom image

Anil  Bist / Professional / Web Technology
 
To post your Question Join Classroom
 
Question No  (14 of 137)
First 10 I 11 I 12 I 13 I 14 I 15 I 16 I 17 I 18 Last
 
Question:-
How do I escape data before storing it into the database?
 
Answer:-
Browser Output 
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt; // view source code output
?>
<a href='test'>Test</a>
htmlspecialchars function enables us to escape data before storage into the database.

<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;
?>

Note:

Note that this function does not translate anything beyond what is listed above. For full entity translation, see htmlentities().

htmlentities() example

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

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?>

addslashes function enables us to escape data before storage into the database.

  
 
 
 
image
Anil  Bist

Skills    Php

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,
Description:-

in 2006, i Join a web development company in Bangalore and start work on "Ruby on Rail" this is my first web development framework and we worked in this framework and develop four to five project after some time , I moved to JEE/Sturst frame work,

After some time i decided that now times come and I have to go on in my own way and I started a company name is "Soarlogic&q
Explore

 

  Students (9)

Ask 
image
shubham
Ask 
Monika
Ask 
Anamika
Ask 
Riya
Ask 
image
Pooja
Ask 
Richa
Ask 
image
prateek
Ask 
Neha
Ask 
image
Amit
 
 

Recommended Classes

Rajendra Kumar
I have more then 5 year of Mobile App Development Experience and have worked in Android Native, I...
Professional
image Anil Bist
in 2006, i Join a web development company in Bangalore and start work on "Ruby on Rail"...
Professional
image Sandeep Srivastava
I am working as software develop from last 9 year.worked in Java, Struts, SpringMVC, Hibernate.
Professional