note 86668 added to ref.pdo-dblib

From: Date: Wed, 29 Oct 2008 02:39:36 +0000
Subject: note 86668 added to ref.pdo-dblib
Groups: php.notes 
Request: Send a blank email to php-notes+get-145916@lists.php.net to get a copy of this message
to connect MS SQL2005(DE) sample code: notice: if u used MSSQL 2005 EXPRESS, must set the instence name 'SQLEXPRESS' just like $hostname='127.0.0.1\SQLEXPRESS'; <?php try { $hostname = "host"; //host $dbname = "dbname"; //db name $username = "user"; // username like 'sa' $pw = "pass"; // password for the user $dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw"); } catch (PDOException $e) { echo "Failed to get DB handle: " . $e->getMessage() . "\n"; exit; } $stmt = $dbh->prepare("SELECT * FROM table"); $stmt->execute(); while ($row = $stmt->fetch()) { print_r($row); } unset($dbh); unset($stmt); ?> ---- Server IP: 210.51.44.91 Probable Submitter: 125.83.42.23 ---- Manual Page -- http://www.php.net/manual/en/ref.pdo-dblib.php Edit -- https://master.php.net/note/edit/86668 Del: integrated -- https://master.php.net/note/delete/86668/integrated Del: useless -- https://master.php.net/note/delete/86668/useless Del: bad code -- https://master.php.net/note/delete/86668/bad+code Del: spam -- https://master.php.net/note/delete/86668/spam Del: non-english -- https://master.php.net/note/delete/86668/non-english Del: in docs -- https://master.php.net/note/delete/86668/in+docs Del: other reasons-- https://master.php.net/note/delete/86668 Reject -- https://master.php.net/note/reject/86668 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145916) next »