exhaler Posted March 24, 2009 Share Posted March 24, 2009 hi, when reading names from mysql i have some names with an apostrophe sush as Aysh A’ssaraya here's my code to insert the names $name = mysql_prep(trim($_POST['name'])); function mysql_prep( $value ) { $magic_quotes_active = get_magic_quotes_gpc(); // i.e. PHP >= v4.3.0 $new_enough_php = function_exists( "mysql_real_escape_string" ); if( $new_enough_php ) { // PHP v4.3.0 or higher // undo any magic quote effects so mysql_real_escape_string can do the 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 already on then add slashes manually if( !$magic_quotes_active ) { $value = addslashes( $value ); } // if magic quotes are active, then the slashes already exist } return $value; } but when i'm displaying them i get an empty square in place of the apostrophe depeding on the browser, (i get a question mark in opera and firefox.) i.e: Aysh A�ssaraya my display code $name = stripslashes($row['name']); echo $name; i tried using htmlentities() but its not working any ideas thanks Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 24, 2009 Share Posted March 24, 2009 is your char encoding ISO? Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 Or maybe you should be using UTF8 with a collation of utf8_bin. Then you will support more characters, also make sure when you extract the characters you are using a utf8 connection. PS MySQL defaults to latin1. Quote Link to comment Share on other sites More sharing options...
exhaler Posted March 25, 2009 Author Share Posted March 25, 2009 thx, turns out that i had this in my header.php <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> which caused the problem i replaced it with this <meta content="text/html; charset=windows-1252" http-equiv="Content-Type" /> and now its fixed should i use another type?? Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 25, 2009 Share Posted March 25, 2009 utf8_bin Google it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.