I try to avoid some data before they enter my database, but I keep getting this error:
Warning: mysql_real_escape_string(): Access denied for user
Now this usually assumes that I have not connected to the database (it also indicates (using password: NO)).
I was a little confused by this because when I connect to the database I have a "die" clause, so if it cannot contact, I will talk about it. So I tested this theory by executing a simple query in the same function that im is trying to avoid data, and this works fine.
So why on earth the escape method will not work or get a connection to the database. I noticed that the user that the error points to is not the user I use to access the database, something like "www-data @localhost". Can he try to log in with another user, if so, why and how? Since the escape function works very well in another area of my website, and I did not do anything special to make it work, I just added the code to my web page.
thanks for the help.
Are there other ways to clear my code?
Okay, so when we submit the form, I use AJAX to collect the data and put it in obj for publication (JSON coding) for the first PHP script, which is located here:
http://codepad.org/kGPljN4I
This script checks all the data and then calls a function to add to the database
this Mysql class is called to delete the data, and then adds a new record to the database, when the class instance is created, it makes a connection to the database:
http://codepad.org/wwGNrTJm
The third file for constants, it contains information for the database, for example pass, user, etc.:
http://codepad.org/dl0QQbi9
it's better?
Thanks again for the help.