|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
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.