Jump to content

Recommended Posts

My department is migrating from SQL 2000 to SQL 2005. I am trying to connect to the SQL 2005 server but keep getting login failures.

[quote]unable to connect to serverPHP Warning: mssql_pconnect() [function.mssql-pconnect]: message: Login failed for user 'kyle'. (severity 14)[/quote]

I am assuming I can use the same connection string for the SQL 2005 server but just change the server name/username/password.
here's what I have
[code]
$hostname_link ="SQLServer2005";
$database_link = "Moldy_Crow";
$username_link = "kyle";
$password_link = "katarn";
$link = mssql_pconnect($hostname_link, $username_link, $password_link) or die("unable to connect to server");
[/code]

I think the password is incorrect but I am not the server administrator. I wanted to get expert advice if this connection string is correct or if there is something wrong with the code. TIA!
Link to comment
https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/
Share on other sites

ahh, thank you. That does explain a lot.
I can connect to the server with my windows authentication but not with the internet guest account that was created. I will have to see if the administrators of the server enabled this or not. I am just a grunt that connects to the database but not the person who administers the database server.
ok,
I can now connect to the database with the other account but now I am having another issue.
I can't get my SQL statement to run from php.

I have a test table called customers in database LEAD with 4 fields (Last_Name, First_Name, etc...)
I created the table under my winNT account.

the table's path looks like: [Domain\MyName_customer].FieldName

I create the following code and execute it:
[code]
require_once('Connect/conn.php');
mssql_select_db("Company");

$SQL_customers=("SELECT First_Name FROM customer");
$Query_display = mssql_query($SQL_customers);

[/code]
Then I get this error:
[quote]PHP Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'customer'. (severity 16)[/quote]

but the table does exist and so does the field.

After this failed, I assumed that since I created this table under my name that the guest account needed permission to view it so I right-clicked on the table, added the guest account with full rights (for testing) and still the same error.

Is there something here that I am missing?
Please help.
Thanks!
try
SELECT First_Name FROM Myname.customer
or
SELECT First_Name FROM [Domain\Myname].customer


If it's a permissions issue, you would get a different error message -- this is definitely that the table is in a different schema.

Alternately, you might try
select * from information_schema.tables
and see what it says in there
MCP thank you for helping me out. Your suggestion was correct:
[quote]SELECT First_Name FROM [domain\myaccount].customer[/quote]
this worked.

however, my problem now is that I don't want to use my account to access the database online, only the internet guest account that was created. It is a little frustrating because I am using the guest account to connect to the database but I have to use my account to select/ display the items. I am modifying the guest account permissions and trying different things. If you have any additional suggestions it will be most welcome.
hmm, you can switch by doing:

alter schema <schema name> transfer <table name>

i think everyone should be able to access the default dbo schema, so maybe use that? or maybe edit the guest.tableName tables to give yourself access?

any of these ways should solve your issues. i wouldn't leave the production tables tied to your account schema, just in case someone else has to take over the project, and then all the names will have to be changed all over the code if you use 2 part names.
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.