Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors resulting from mysql_real_escape_string #30

Closed
dleehr opened this issue Sep 18, 2014 · 1 comment
Closed

Errors resulting from mysql_real_escape_string #30

dleehr opened this issue Sep 18, 2014 · 1 comment
Labels

Comments

@dleehr
Copy link
Member

dleehr commented Sep 18, 2014

When visiting the browse page, I see php warnings:

    [Thu Sep 18 15:11:05 2014] [error] [client 10.0.2.2] PHP Warning:  mysql_real_escape_string(): Access denied for user 'apache'@'localhost' (using password: NO) in /opt/webapps/FossilCalibrations/FCD-helpers.php on line 354, referer: https://xxxx/search.php?x=4&y=18&SimpleSearch=f
    [Thu Sep 18 15:11:05 2014] [error] [client 10.0.2.2] PHP Warning:  mysql_real_escape_string(): A link to the server could not be established in /opt/webapps/FossilCalibrations/FCD-helpers.php on line 354, referer: https://xxxx/search.php?x=4&y=18&SimpleSearch=f

Based on the documentation for mysql_real_escape_string, it will use the last DB link connected with mysql_connect. However, if you connected with mysqli_connect (and not mysql_connect), the link will not be set. In this case, mysql_real_escape_string falls back to trying to connect with the local user, which fails.

So I'd suggest to change this to mysqli_real_escape_string, but that may trigger the opposite warning for code that's using mysql_connect.

@dleehr
Copy link
Member Author

dleehr commented Sep 18, 2014

Note that this is a PHP warning, not an error. It appears to be escaping the string still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants