Jump to content

mssql_select_db problem


Recommended Posts

Hi,

 

We are running a now quite outdated PHP installation (4.3.0) on W2K with MSSql.

 

The PHP is working fine and I can connect to the sql server without any problems.

 

However, I can only successfully run queries if I use the database name in the query.

 

Eg. SELECT * FROM person  ..... fails with this message:

Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'person'. (severity 16)

 

BUT .... if the query is SELECT * FROM database_name.person ..... it's works fine

 

I am using mssql_select_db('database_name') immediately after I connect, but it doesn't seem to do anything.

 

-----------------------------

$conn = mssql_pconnect($sqlserver , $sqluser , $sqlpass);

mssql_select_db($database);

$result = mssql_query("SELECT * FROM person", $conn);

------------------------------

 

Any ideas?

 

Thanks

Jon.

Link to comment
Share on other sites

Just discovered that all my queries work fine if I connect to the Northwind database ie. I don't have to put the database name in the query ....

 

BUT .... my database still requires the db_name in there.

 

Any help would be appreciated.

 

Tks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.