-4

I would like to make the users profile public or private and I have coded something in PHP. But I am getting following error:

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'gooyanet'@'localhost' (using password: NO) on line 7

And also:

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established on line 7

Here is a link to my code.

It would be great if you help me with that ...

lxg
  • 12,375
  • 12
  • 51
  • 73
  • It's nothing to do with `mysql_real_escape_string`, your MySQL login credentials are incorrect or your user doesn't have permission on that database. – MrCode Oct 19 '14 at 15:02
  • It's because you haven't got a working database connection configured. – Quentin Oct 19 '14 at 15:03
  • 1
    The problem could indeed be with your connection credentials, please check them. And do stop using mysql_real_escape_string, use prepared statements instead. – gd1 Oct 19 '14 at 15:03
  • You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). A modern API has better ways to [deal with SQL injection](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) than real_escape_string. – Quentin Oct 19 '14 at 15:03

1 Answers1

2

Since you havnt provided the code the problem may be due to the connection credentials given in your code.

The use of mysql_real_escape_string() is depreciated.Use PDO instead and stay safe from sql injection.

Avinash Babu
  • 6,171
  • 3
  • 21
  • 26