ThreeTrees Posted August 5, 2008 Share Posted August 5, 2008 Hi I recently had to change my database from mysql to sql. with mysql I didnt have any problem but now I cant connect to the sql database. here's the sql connection code <?php $myServer = "localhost"; $myUser = "sa"; $myPass = "mypassword"; $myDB = "mmt"; $dbhandle = mssql_connect($myServer, $myUser) or die("Couldn't connect to SQL Server on $myServer"); $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); mssql_close($dbhandle); ?> and thats the mysql connection if that helps ?php $con= mysql_connect('localhost','root') or die ('cannot connect bla bla' . mysql_error()); if (!$con) { echo 'WHAT THE FUCK CONNECTION ISNT WORKING'; } mysql_select_db('mmt') or die ('db fail' . mysql_error()); if (!mysql_select_db('mmt')) { echo ' OH NOES UNDER DAS VEINDER DATABASE'; } ?> Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/ Share on other sites More sharing options...
JonnyThunder Posted August 5, 2008 Share Posted August 5, 2008 So what error are you seeing??? Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/#findComment-608508 Share on other sites More sharing options...
ThreeTrees Posted August 5, 2008 Author Share Posted August 5, 2008 Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: MORS-010A604462\SQLEXPRESS in C:\wapache\htdocs\db.inc.php on line 7 Couldn't connect to SQL Server on MORS-010A604462\SQLEXPRESS Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/#findComment-608518 Share on other sites More sharing options...
Ace Jon Posted August 5, 2008 Share Posted August 5, 2008 How long ago did you switch to SQL? If it was a short time, it's possible that thnigs haven't... connected... yet. Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/#findComment-608520 Share on other sites More sharing options...
ThreeTrees Posted August 5, 2008 Author Share Posted August 5, 2008 How long ago did you switch to SQL? If it was a short time, it's possible that thnigs haven't... connected... yet. I have it for a few days and Im able to connect it using the sql manager could it be that my connection script is wrong? if any of you guys know any better script it would probably help Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/#findComment-608524 Share on other sites More sharing options...
vikramjeet.singla Posted August 5, 2008 Share Posted August 5, 2008 please use this <?php $myServer = "localhost"; $myUser = "sa"; $myPass = "mypassword"; $myDB = "mmt"; $dbhandle = mssql_connect($myServer, $myUser, $myPass ) or die("Couldn't connect to SQL Server on $myServer"); $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); mssql_close($dbhandle); ?> you have not mentioned the password while connecting to sql server Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/#findComment-608531 Share on other sites More sharing options...
ThreeTrees Posted August 5, 2008 Author Share Posted August 5, 2008 please use this <?php $myServer = "localhost"; $myUser = "sa"; $myPass = "mypassword"; $myDB = "mmt"; $dbhandle = mssql_connect($myServer, $myUser, $myPass ) or die("Couldn't connect to SQL Server on $myServer"); $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); mssql_close($dbhandle); ?> you have not mentioned the password while connecting to sql server gives me the same error Link to comment https://forums.phpfreaks.com/topic/118239-help-with-connecting-to-sql/#findComment-608565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.