php - MySQL PHPMyAdmin Localhost to accept Magic Quotes -
i'm having small problem localhost on ubuntu accept data posted apostrophes php file mysql database.
example:
it's birthday!   will not accepted localhost database , won't accept coming either.
example:
its birthday!   will accepted localhost database , else coming long there's no apostrophes posted.
how can local machine act server online accepts apostrophes data posted database? more ensuring me code works while developing.
i want make localhost servers accepts data without using mysql_real_escape_string().
you need escape string before inserting database using mysql_real_escape_string() function see it's docs here
update: should put magic_quotes_gpc 'on' in php.ini file make server escape special characters adding \  before them addslashes() php function recommend use mysql_real_escape_string() function because makes mysql escape string , it's better add slashes function or can use function function use :
function mysql_prep($value) {   $magic_quotes_active = get_magic_quotes_gpc();   $new_enough_php = function_exists( "mysql_real_escape_string" );         // i.e. php >= v4.3.0   if( $new_enough_php )  // php v4.3.0 or higher   {             // undo magic quote effects mysql_real_escape_string can work     if( $magic_quotes_active )      {       $value = stripslashes( $value );     }      $value = mysql_real_escape_string( $value );   } else // before php v4.3.0      {        // if magic quotes aren't on add slashes manually          if( !$magic_quotes_active )           {           $value = addslashes( $value );           }     // if magic quotes active, slashes exist       }   return $value;  }      
Comments
Post a Comment