Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cant get rid of Apostrophes keep getting backslashes

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Each time I enter a name with an Apostrophy ikeep getting

backslashes eg O'keeffe becomes O/'keeffe

Here is a sample of the code what I'm using

// Function for escaping and trimming form data.

function escape_data ($data)
{
global $dbc;
if (ini_get('magic_quotes_gpc'))
{
$data = stripslashes($data);
}
return mysql_real_escape_string (trim ($data), $dbc);
} // End of escape_data() function



// Validation Code


// Check for a username

if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username']))))

{
$u = escape_data($_POST['username']);
}

else
{
$u = FALSE;
echo '<p class="validation">Please enter a valid username!</p>';
}


// Form Code

<tr>
<td colspan="2" class="labelcell"><label for = "username">1. Username</label></td>
<td colspan="2" class="fieldcell"><input type="text" name="username" size="20" maxlength="20"
value="<?php if(isset($_POST['username'])) echo $_POST['username'];?>"/>
</td>
</tr>



What am I doing wrong trying to fix it for the last 3 weeks

driving me crazy.

Tks

Gaz

 
You don't say where you're seeing the escaped quotes, but I will assume you're seeing them in
Code:
<td colspan="2" class="fieldcell"><input type="text" name="username" size="20" maxlength="20"
value="<?php if(isset($_POST['username'])) echo $_POST['username'];?>"/>
Just change the "echo $_POST['username']" to "echo stripslashes($_POST['username'])".

If that's not where you're seeing them, let us know where.

Ken
 
Ken

Great Stuff worked a treat, i'm new to this stuff.

Many thanks my friend

Gaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top