-
-
Save serverok/456b3d1d7295463df42c9822e8db3e5b to your computer and use it in GitHub Desktop.
PHP Script to connect to MS SQL
This file contains 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
<?php | |
# PHP Script to connect to MS SQL | |
# Install MS SQL Driver as per | |
# https://serverok.in/install-php-drivers-for-microsoft-sql-server-on-ubuntu-php-7-2 | |
$serverName = "tcp:ec2-3-13-16-20.us-east-2.compute.amazonaws.com,1433"; | |
$database = "articles_db"; | |
$uid = "serverok"; | |
$pwd = "server#xuzok"; | |
$conn = new PDO("sqlsrv:server=$serverName ; Database = $database", $uid, $pwd); | |
$tsql = "SELECT TOP (50) * FROM [articles_db].[dbo].[ARTICLE] ORDER BY [ART_ID] DESC"; | |
$getArticle = $conn->query($tsql); | |
var_dump($conn->errorInfo()); | |
echo "<pre>"; | |
while ($row = $getArticle->fetch(PDO::FETCH_ASSOC)) { | |
print_r($row); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment