php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33700 mysql_real_escape_string does NOT require a mysql connection
Submitted: 2005-07-14 17:54 UTC Modified: 2005-07-15 08:02 UTC
From: colder@php.net Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: WinXP
Private report: No CVE-ID: None
 [2005-07-14 17:54 UTC] colder@php.net
Description:
------------
mysql_real_ecape_string does not require a mysql connection.

That makes the first note wrong:
"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."

This function doesn't generate a WARNING and doesn't return FALSE when no connexion is available.

I don't know when this behavior changed so I'm unable to provide a patch, sorry.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-15 08:02 UTC] vrana@php.net
It's the same as with any other MySQL function. If no link_identifier is provided and no link does exist, connection is tried to establish with default user/password defined in php.ini. If this fails, mysql_real_escape_string() really generates WARNING and returns FALSE.

I documented that in CVS at ref.mysql instead: "Most MySQL functions accept link_identifier as the last optional parameter. If it is not provided, last opened connection is used. If it doesn't exist, connection is tried to establish with default parameters defined in php.ini. If it is not successful, functions return FALSE."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC