PHP‎ > ‎

Use PHP PDO to execute parameterized select statement


Apparently, you cannot use an ADO connection to a Microsoft SQL Server database in PHP and use a parameter query.

So you have to you the PHP PDO connection type:



$pdo = new PDO ("sqlsrv:server=myserver\SQLEXPRESS;Database=mydatabase", "myuserid", "mypassword");
$stmt = $pdo->prepare("select * from icb_weblogins where userid =?");
$stmt->bindParam(1, $userid);
$userid="djohnson@icbconsulting.com";
$stmt->execute();



Comments