Tuesday, 28 June 2011

Insert string with single quote (') in DB

string addslashes ( string $str )

For example, to insert the name O'reilly into a database, you will need to escape it.

<?php
$str 
"Is your name O'reilly?";// Outputs: Is your name O\'reilly?echo addslashes($str);?>
 
This would only be to get the data into the database, the extra \ will not be inserted. 

No comments:

Post a Comment