473,498 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 29519
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7609
by: Marcus | last post by:
Hello, My php.ini file currently has magic quotes set to On, but I have read that it is better to code with it off. Currently with magic quotes on, I only use stripslashes() to properly...
4
3097
by: JM Ivler | last post by:
Is there really any time when I don't want to run every _POST and _GET through mysql_real_escape_string() before I use that data in accessing the database? In other words, is there a good reason...
2
2886
by: matthud | last post by:
<?php //MAKE IT SAFE $chunk = $_POST; $title = $_POST; $url = $_POST; $tags = $_POST; $user = $_POST; $safe_chunk = mysql_real_escape_string(htmlentities($chunk)); $safe_title =...
5
2375
by: vivek | last post by:
Could someone please help me figure out why the memory usage fluctuates when I use mysql_real_escape_string? I'm finding (what I think are) memory leaks with a few mysql functions in php and I'm...
11
2716
by: zach | last post by:
I created a comment form which will inserts the comments into a database and displays them immediately. I want to make sure that its safe from users inserting unwanted data into the database or...
6
3754
by: redog6 | last post by:
Hi I have a webform with many free text fields and have a problem with apostrophes and single quotes as this breaks the mysql query string. I obviously need to escape these characters -...
13
3447
by: ndlarsen | last post by:
Hello. It's been a while since I used php. Since then magic quotes has been deprecated and will be removed when php 6.0 hits. My question is, what should I be using when submitting data to a...
5
1812
by: Mandragon03 | last post by:
I am using mysql_real_escape_string for the input of a form before it is updated into the mysql database. Somthing like this: $realHTMLText = mysql_real_escape_string($_POST); $id =...
7
5134
by: roseple | last post by:
Hi, can anyone please help me why I got this error every I uploaded files. Error: Here is the code on the said warning message: # Gather all required data $name =...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.