An example of a basic MSSQL (Microsoft SQL Server/SQL Server Express) query using PHP.
1 2 3 4 5 6 7 8 9 |
$szQry = "SELECT column1, column2 FROM foo"; $szDBConn = mssql_connect("host","username","password"); mssql_select_db("database_name", $szDBConn); $saResults = mssql_query($szQry, $szDBConn); while($obResults = mssql_fetch_row($saResults)) { echo $obResults[0]." ".$obResults[1]; } mssql_close($szDBConn); |
Comments/description of Example
- Line #1
- SQL statement that will be sent to the MySQL database server.
- Line #2
- MSSQL database login credentilas; host (127.0.0.1), username and password.
- The “host” is the server name or IP address of your database server. If your host has multiple instances the “host” value would be formatted like so …