Created
February 28, 2014 13:01
-
-
Save alphabraga/9270663 to your computer and use it in GitHub Desktop.
Simple code for connect with mssql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error_reporting(-1); | |
ini_set('display_errors', 'On'); | |
ini_set("display_errors",1); | |
ini_set("error_reporting",E_ALL); | |
$conn = mssql_connect('localhost','user', 'pass'); | |
mssql_select_db('database', $conn); | |
$result = mssql_query("select * from table", $conn); | |
if(!$result){ | |
var_dump(mssql_get_last_message()); | |
die('MSSQL error: ' . mssql_get_last_message()); | |
} | |
if($result === true){ | |
var_dump('result', $result); | |
die; | |
} | |
$rows = mssql_fetch_assoc($result); | |
if(!$rows){ | |
die('MSSQL error: ' . mssql_get_last_message()); | |
}else{ | |
var_dump($rows); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment