note 116802 added to function.odbc-connect
| From: | Luis | Date: | Mon, 02 Mar 2015 17:48:29 +0000 |
| Subject: | note 116802 added to function.odbc-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201839@lists.php.net to get a copy of this message | ||
Following simonr at no2sp at m dot cogapp dot com contribution (thank you), I tried to connect to a
local MS SQL Server 2014 Express database by creating a DSN-less connection using ODBC. It worked,
here's the code.
<?php
// Replace the value of these variables with your own data
$user = 'username';
$pass = 'password';
$server = 'serverName\instanceName';
$database = 'database';
// No changes needed from now on
$connection_string = "DRIVER={SQL Server};SERVER=$server;DATABASE=$database";
$conn = odbc_connect($connection_string,$user,$pass);
if ($conn) {
echo "Connection established.";
} else{
die("Connection could not be established.");
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 85.242.85.49
----
Manual Page -- http://php.net/manual/en/function.odbc-connect.php
Edit -- https://master.php.net/note/edit/116802
Del: integrated -- https://master.php.net/note/delete/116802/integrated
Del: useless -- https://master.php.net/note/delete/116802/useless
Del: bad code -- https://master.php.net/note/delete/116802/bad+code
Del: spam -- https://master.php.net/note/delete/116802/spam
Del: non-english -- https://master.php.net/note/delete/116802/non-english
Del: in docs -- https://master.php.net/note/delete/116802/in+docs
Del: other reasons-- https://master.php.net/note/delete/116802
Reject -- https://master.php.net/note/reject/116802
Search -- https://master.php.net/manage/user-notes.php