mysql_real_escape_string() cannot connect to database..??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • comp.lang.php

    mysql_real_escape_string() cannot connect to database..??

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

    Warning: mysql_real_esca pe_string()
    [function.mysql-real-escape-string]: Access denied for user
    'web'@'localhos t' (using password: NO) in
    /home/me/web/include/secondary/app_action.inc. php on line 337

    Warning: mysql_real_esca pe_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_esca pe_string() doing connecting to the
    database, as 'web' or anyone else, and thirdly, why is this happening,
    does anyone know?

    Thanx
    Phil

  • Kim André Akerø

    #2
    Re: mysql_real_esca pe_string() cannot connect to database..??

    comp.lang.php wrote:
    when trying to use the mysql_real_esca pe_string() function, the
    following warning occurs:
    >
    Warning: mysql_real_esca pe_string()
    [function.mysql-real-escape-string]: Access denied for user
    'web'@'localhos t' (using password: NO) in
    /home/me/web/include/secondary/app_action.inc. php on line 337
    >
    Warning: mysql_real_esca pe_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_esca pe_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_strin g, 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_esca pe_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ø
    - kimandre@NOSPAM betadome.com
    (remove NOSPAM to contact me directly)

    Comment

    • Johnny

      #3
      Re: mysql_real_esca pe_string() cannot connect to database..??


      "comp.lang. php" <phillip.s.powe ll@gmail.comwro te in message
      news:1160550516 .487814.83740@k 70g2000cwa.goog legroups.com...
      when trying to use the mysql_real_esca pe_string() function, the
      following warning occurs:
      >
      Warning: mysql_real_esca pe_string()
      [function.mysql-real-escape-string]: Access denied for user
      'web'@'localhos t' (using password: NO) in
      /home/me/web/include/secondary/app_action.inc. php on line 337
      >
      Warning: mysql_real_esca pe_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_esca pe_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_esca pe_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_esca pe_string("some text"); ?>

      Warning: mysql_real_esca pe_string() [function.mysql-real-escape-string]:
      Access denied for user: 'ODBC@localhost ' (Using password: NO) in i:\program
      files\apache group\apache\ht docs\mres.php on line 1

      but on my remote server the same thing gives:
      Warning: mysql_real_esca pe_string(): Access denied for user:
      'nobody@localho st' (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.


      Comment

      Working...