472,951 Members | 2,301 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

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 29481
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
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
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
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
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
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
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
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
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
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 =...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.