Jump to content

[SOLVED] empty square instead of an apostrophe


exhaler

Recommended Posts

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

 

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.