php.net |  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 - 12 = ?
Subscribe to this entry?

 
 [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.

$server="SQL-Server";
$dbName="My-DB";
$user="phpusr";
$passwd="phppass";

$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'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

mssql_select_db("[my database]");

or 

mssql_select_db("[my-database]");

That works fine.

 [2002-02-02 00:16 UTC] yohgaki@php.net
In PHP bug db, cloased is used for fixed bugs/problems.
Bogus should be the correct status :)
 [2002-02-02 03:33 UTC] mfischer@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC