| Subcribe via RSS

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]:

March 2nd, 2008 Posted in anything under the moonlight, php by dreamluverz

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user ‘apache’@'localhost’ (using password: NO)…



I’m having that error for using mysql_real_escape_string in one of my functions. Checked php manual and it says u need to have mysql connection to use that. :P well.. my bad…coz I’m using it in a variable before putting in a query. This is an example on how to use it anyway…




// Connect
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
OR die(mysql_error());

// Query
$query = sprintf(”SELECT * FROM users WHERE user=’%s’ AND password=’%s’”,
mysql_real_escape_string($user),
mysql_real_escape_string($password));
?>

Leave a Reply