PDA

Click to See Complete Forum and Search --> : [RESOLVED] php to MSSQL connection


downat420
Dec 7th, 2009, 08:31 PM
I am trying to connect to a godaddy hosted MSSQL database with php. here is my connection string with generic information:

<?php
$myServer = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
$myUser = "username";
$myPass = "password";
$myDB = "dbname";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");


what am I doing wrong? it fails at

mssql_connection



thanks everyone.

Nightwalker83
Dec 7th, 2009, 08:41 PM
That would appear to be a slight spelling mistake:


$dbhandle = mysql_connect($myServer, $myUser, $myPass)

kows
Dec 7th, 2009, 08:54 PM
.. lol.

no, it's not a spelling mistake. MSSQL is another type of database (Microsoft SQL Server), and PHP supports it with functions similar to the MySQL functions; they are prefixed with "mssql_."

talk to your host and ensure you are using the right server. I know that godaddy has incredibly weird URLs for their MySQL servers, so they might do the same for MSSQL. you could also ask if they might be able to provide some sample code to connect to their MSSQL server -- but, I'm not sure they would be able to provide it.

edit: also, make sure you're specifying a port in $myServer whenever you're trying to connect; this would be in the format: server:port

downat420
Dec 7th, 2009, 09:03 PM
I sent a help request to godaddy before I came here. I was confident in the php but thought I would check.

I will post the solution if godaddy is able to help me out.

Thanks so far. If anyone notices something I am missing or has a similar godaddy experience I still consider this open.

Nightwalker83
Dec 7th, 2009, 09:10 PM
I'm not sure if this (http://help.godaddy.com/article/3322) would help.


Where can I find database connection strings for my MS SQL database?

Connection strings can be found in the Hosting Control Center.

1. Log in to your Account Manager.
2. In the My Products section, select Hosting.
3. Next to the hosting account you want to modify, click Manage Account.
4. In the Databases section of the Hosting Control Center, click the SQL server icon.
5. Click the pencil icon next to the database you would like to get connection strings for to open its edit features.
6. Click the Configuration icon in the menu bar.

downat420
Dec 7th, 2009, 09:15 PM
they do not put a PHP string in there. it would be nice if they did.

i might have to wait for godaddy to get back with me on this one. google has not been very helpful.

downat420
Dec 8th, 2009, 07:04 PM
so here is the solution: switch to mysql / PHP solution.

this was the response from Godaddy.

Dear SirMadam,

Thank you for contacting Online Support.

I apologize for any inconvenience this may have caused. Unfortunately connecting to MS SQL via PHP is not supported.

thanks everyone for your help.

Nightwalker83
Dec 9th, 2009, 12:10 AM
so here is the solution: switch to mysql / PHP solution.

this was the response from Godaddy.



thanks everyone for your help.

What type of account do you have with godaddy?

I just found this (http://blog.godaddyhosting.com/2006/07/27/go-daddy-offers-dedicated-hosting-with-ms-sql-2005.aspx). Looks like you can only get MSSQL on Windows Server 2003 dedicated hosting with godaddy.

downat420
Dec 9th, 2009, 12:48 AM
a windows box, not dedicated, 5 bucks. i get 1 mssql database included or 1000 mysql databases. it is just easier to use mysql. i have no real reason for using mssql except i am more familiar with it.

SambaNeko
Dec 9th, 2009, 10:35 AM
I apologize for any inconvenience this may have caused. Unfortunately connecting to MS SQL via PHP is not supported.

I have to wonder why... Probably just GoDaddy being GoDaddy I guess; I buy domains from them, but I don't think I've heard anything good about their hosting...

kows
Dec 9th, 2009, 10:55 AM
I don't like their hosting and the way they have it set up -at all-, it's incredibly annoying. it might be nice for novice "web masters," but I just can't stand it.

however, I refuse to go anywhere else for domains.

downat420
Dec 9th, 2009, 08:34 PM
thanks for the novice and "web masters" remark.

i have used them for years. i have used worse hosting services. they are cheap.

Nightwalker83
Dec 9th, 2009, 09:38 PM
I don't like their hosting and the way they have it set up -at all-, it's incredibly annoying. it might be nice for novice "web masters," but I just can't stand it.


Neither can I! I also find their website layout confusing to navigate too.