Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried doing this:

@ $db = new myConnectDB();

$beerName = mysql_real_escape_string($beerName);
$beerID = mysql_real_escape_string($beerID);
$brewery = mysql_real_escape_string($brewery);
$style = mysql_real_escape_string($style);
$userID = mysql_real_escape_string($userID);
$abv = mysql_real_escape_string($abv);
$ibu = mysql_real_escape_string($ibu);
$breweryID = mysql_real_escape_string($breweryID);
$icon = mysql_real_escape_string($icon);

I get this error:

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user

share|improve this question

closed as off topic by Su', danlefree Sep 2 '12 at 18:34

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Are you sure the connection was successful? Usually you get this error when there's no connection. However I think this post might be better suited for Stack Overflow. – milo5b Aug 30 '12 at 21:13
Why are you suppressing errors in the first line of code (where you presumably create the DB connection) with the @ operator? Which MySQL extension are you using to connect to your DB? – w3dk Aug 30 '12 at 22:48
Thanks I will try it on stack. – Mike Aug 30 '12 at 23:13
Solution here: stackoverflow.com/a/12223427/369434 – w3dk Aug 31 '12 at 23:38

All of PHP's mysql_* functions, including mysql_real_escape_string() have been deprecated, in favour of the mysqli and PDO extensions.

See Deprecated PHP (A blog set up by two StackOverflow members).

Use query binding (SELECT * FROM table WHERE ? with a $condition) and you won't have to use the function you mention.

share|improve this answer
Still lots of old application use the old mysql connector, and you might not want to refactor. This solution would not solve the problem, as the error is not thrown because the functions have been deprecated, but for other reasons (probably missing connection). – milo5b Aug 31 '12 at 9:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.