No, stripslashes job is to remove any slashes added by magic_quotes. But you need to make sure you're only striping IF magic quotes is enabled, otherwise you pose a risk of removing slashes intended (such as when you posted the string here). You're seeing the slash either because it was inserted that way, so O'Connell has become O\\\'Connel, or you have magic_quotes_runtime enabled. You can only tell this if you check the data directly from a SQL tool, or by checking the ini setting. Fortunately that can be disabled at runtime. Both of these are now deprecated, too bad we need to account for them.
PHP Code:
if (function_exists('set_magic_quotes_runtime'))
{
set_magic_quotes_runtime(0);
}
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
{
$_POST['last_name'] = stripslashes($_POST['lastname']);
}
$last_name = mysql_real_escape_string($_POST['lastname']);
Fortunately, magic quotes will be gone soon. As of 5.4, register_globals are gone, so I'm happy enough with that. For now.
Edit:
Oh yeah, btw MySQLi can get around this using prepared statements instead.