468,505 Members | 1,559 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

mysql_real_escape_string() cannot connect to database..??

when trying to use the mysql_real_escape_string() function, the
following warning occurs:

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

Oct 11 '06 #1
2 29164
comp.lang.php wrote:
when trying to use the mysql_real_escape_string() function, the
following warning occurs:

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
Have you connected to your MySQL database yet?

From the manual:
-----------------------------
Escapes special characters in the unescaped_string, taking into account
the current character set of the connection so that it is safe to place
it in a mysql_query(). If binary data is to be inserted, this function
must be used.
-----------------------------
Note: A MySQL connection is required before using
mysql_real_escape_string() otherwise an error of level E_WARNING is
generated, and FALSE is returned. If link_identifier isn't defined, the
last MySQL connection is used.
-----------------------------

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Oct 11 '06 #2

"comp.lang.php" <ph**************@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
when trying to use the mysql_real_escape_string() function, the
following warning occurs:

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.
Oct 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Marcus | last post: by
4 posts views Thread by JM Ivler | last post: by
2 posts views Thread by matthud | last post: by
5 posts views Thread by vivek | last post: by
11 posts views Thread by zach | last post: by
13 posts views Thread by ndlarsen | last post: by
5 posts views Thread by Mandragon03 | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.