Shazbot! Posted January 11, 2007 Share Posted January 11, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/ Share on other sites More sharing options...
MCP Posted January 12, 2007 Share Posted January 12, 2007 By default, SQL Server 2005 is not set up for sql security (will only use windows authentication). You'll have to enable this on your server if you haven't already... Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-158813 Share on other sites More sharing options...
Shazbot! Posted January 12, 2007 Author Share Posted January 12, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-159104 Share on other sites More sharing options...
Shazbot! Posted January 12, 2007 Author Share Posted January 12, 2007 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].FieldNameI 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! Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-159405 Share on other sites More sharing options...
MCP Posted January 13, 2007 Share Posted January 13, 2007 trySELECT First_Name FROM Myname.customerorSELECT First_Name FROM [Domain\Myname].customerIf 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 tryselect * from information_schema.tablesand see what it says in there Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-159776 Share on other sites More sharing options...
Shazbot! Posted January 16, 2007 Author Share Posted January 16, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-161973 Share on other sites More sharing options...
MCP Posted January 17, 2007 Share Posted January 17, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-162513 Share on other sites More sharing options...
Shazbot! Posted January 17, 2007 Author Share Posted January 17, 2007 Thank you MCP,I will try that. I also picked up a few books and will see if I can correct the problem.And you're right, I don't want the tables attached to my name. Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-163090 Share on other sites More sharing options...
Shazbot! Posted January 18, 2007 Author Share Posted January 18, 2007 update,The problem was a permissions issue. I tried setting the permissions on my end but the guest account only had read access.This was changed by the server admin.Thanks again for your help! Quote Link to comment https://forums.phpfreaks.com/topic/33808-connecting-to-sql-2005/#findComment-163755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.