mysql_escape_string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ehause
Forum Newbie
Posts: 9
Joined: Sat Apr 17, 2004 8:12 am

mysql_escape_string

Post by ehause »

Hi all:

I'm using MySQL 4.0.18, trying to run the mysql_escape_string on my form variables, and when I submit the form, I get this error one time for each var I'm apllying the string to:

Warning: Wrong parameter count for mysql_escape_string() in /home/souther2/public_html/register.php on line 18

Here's the code for the string:

// Create a function for escaping the data.
function escape_data ($data) {
global $dbc; // Need the connection.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_escape_string($data, $dbc);
} // End of function.

And here's how I'm applying it to the variables:

$fn = escape_data($_POST['first_name']);

Any ideas? Thanks in advance!
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Code: Select all

// Create a function for escaping the data. 
function escape_data ($data) 
    { 
    if (ini_get('magic_quotes_gpc')) 
        { $data = stripslashes($data); } 
    return mysql_escape_string($data); 
    } // End of function.
mysql_escape_string only takes one argument. That's what the error message was about. Go to php.net and check the manual.

Cheers,
BDKR
Post Reply