|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15338 Can't select database with '-' in name.
Submitted: 2002-02-01 19:46 UTC Modified: 2002-02-04 10:15 UTC
From: mikef at microtech dot com Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.1.1 OS: windows NT IIS
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.
Block user comment
Status: Assign to:
Bug Type:
From: mikef at microtech dot com
New email:
PHP Version: OS:


 [2002-02-01 19:46 UTC] mikef at microtech dot com
I have a database on my MSSQL server with a '-' in the database name.  The database works fine with all of my other applications including ASP.  However, I cannot select the database with PHP.  Interestingly, a '-' in the server name doesn't seem to be a problem.


$hcon = mssql_connect($server, $user, $passwd);
if ($hcon == FALSE)
	die("Could not connect to SQL server '$server'");
$hdb = mssql_select_db($dbName, $hcon);

The resulting message is:

Warning: MS SQL message: Line 1: Incorrect syntax near '-'. (severity 15) in C:\InetPub\PHP\dbtest.php on line 10

Warning: MS SQL: Unable to select database: My-DB in C:\InetPub\PHP\dbtest.php on line 10
Could not select database 'My-DB'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-01 20:00 UTC]
If your database name contains '-' or ' ' you can select the database like this:

mssql_select_db("[my database]");



That works fine.

 [2002-02-02 00:16 UTC]
In PHP bug db, cloased is used for fixed bugs/problems.
Bogus should be the correct status :)
 [2002-02-02 03:33 UTC]
It is feedback until the submitter reports something back.
 [2002-02-04 10:15 UTC] mikef at microtech dot com
Sorry for what apparently was simply an SQL syntax issue.  The [My-DB] works just fine.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Dec 04 06:05:52 2022 UTC