"comp.lang.php" <phillip.s.powell@gmail.comwrote in message
news:1160550516.487814.83740@k70g2000cwa.googlegro ups.com...
Quote:
when trying to use the mysql_real_escape_string() function, the
following warning occurs:
>
Quote:
Warning: mysql_real_escape_string()
[function.mysql-real-escape-string]: Access denied for user
'web'@'localhost' (using password: NO) in
/home/me/web/include/secondary/app_action.inc.php on line 337
>
Warning: mysql_real_escape_string()
[function.mysql-real-escape-string]: A link to the server could not be
established in /home/me/web/include/secondary/app_action.inc.php on
line 337
>
First of all, the user is not 'web' trying to connect to the database,
secondly, what is mysql_real_escape_string() doing connecting to the
database, as 'web' or anyone else, and thirdly, why is this happening,
does anyone know?
>
Thanx
Phil
>
if you are on an apache system then PHP is likely running as other (out of
user/group/other) and as a result may well be seen as 'web'
you don't give any context other than a line number for the error so it
makes it a litle harder to intuit what might be happening.
you could change the error reporting to notice to see extra warnings
A MySQL connection is required before using mysql_real_escape_string()
otherwise an error of level E_WARNING is generated...
so it may be that you don't have a valid mysql connection but without seeing
the context who knows?
here's what happens on my local server when I call that without a db link:
<?php echo mysql_real_escape_string("some text"); ?>
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]:
Access denied for user: 'ODBC@localhost' (Using password: NO) in i:\program
files\apache group\apache\htdocs\mres.php on line 1
but on my remote server the same thing gives:
Warning: mysql_real_escape_string(): Access denied for user:
'nobody@localhost' (Using password: NO)in
/home/user/public_html/sitename/mres.php on line 1
so as you can see the user that appears in the error depends on how your
sever is configured.