php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24496 mssql_select_db doesn't accept database names with whitespaces
Submitted: 2003-07-04 08:34 UTC Modified: 2003-07-05 16:48 UTC
From: mheuser at a-tune dot de Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 4.3.2 OS: Windows 2000 SP4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mheuser at a-tune dot de
New email:
PHP Version: OS:

 

 [2003-07-04 08:34 UTC] mheuser at a-tune dot de
Description:
------------
The mssql_select_db function does not accept any whitespaces in the database name string nor decimal numbers at the front. If I replace the whitespaces with something else (like _) and cut the numbers out or let them trail the string, no error occurs and the command is performed correctly.
The code line given in the error messages at the bottom of this page, are actually in the PEAR::MDB package. I located the line in the source code:

if(!mssql_select_db($this->database_name, $this->connection)) {
   return($this->mssqlRaiseError());
}



Reproduce code:
---------------
$dbDatabase = "030616 td@demo mhe";
// or
$dbDatabase = "td@demo mhe 030616";
mssql_select_db($dbDatabase); // Connection to DBMS server was already made successfully



Expected result:
----------------
I'd expect no error message which means a successfully selected database.

Actual result:
--------------
// Error message
Warning: mssql_select_db(): message: Zeile 1: Falsche Syntax in der N?he von '030616'. (severity 15) in C:\PHP\pear\MDB\mssql.php on line 417

// and for the second example
Warning: mssql_select_db(): message: Zeile 1: Falsche Syntax in der N?he von 'mhe'. (severity 15) in C:\PHP\pear\MDB\mssql.php on line 417

In both examples the error occurs when calling mssql_select_db (see description on top of this page for the source code line).



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-05 16:48 UTC] fmk@php.net
The MSSQL syntax for handling white spaces in identifiers is to use [] arround the name.

$dbDatabase = "[030616 td@demo mhe]";
// or
$dbDatabase = "[td@demo mhe 030616]";

Will work.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC