Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php bindParam错误_Php_Sql_Pdo - Fatal编程技术网

Php bindParam错误

Php bindParam错误,php,sql,pdo,Php,Sql,Pdo,我使用的bindParam与下面的示例一样,但它给出了一个错误 错误是无法获得任何响应 $con = new PDO('odbc:Driver={SQL Server};Server='.$db_ip.';Database='.$db_name,$db_user,$db_pass); $m_id=585948; $sql="select n_id from users where m_id = :member "; $sth = $con->prepare($sql); $sth->

我使用的bindParam与下面的示例一样,但它给出了一个错误

错误是无法获得任何响应

$con = new PDO('odbc:Driver={SQL Server};Server='.$db_ip.';Database='.$db_name,$db_user,$db_pass);

$m_id=585948;
$sql="select n_id from users where m_id = :member ";
$sth = $con->prepare($sql);
$sth->bindParam(':member', $m_id);
$sth->execute();

while ($row = $sth->fetch(PDO::FETCH_ASSOC)){
echo $row['n_id'];
}
请尝试以下方法:

$sth = $con->prepare($sql);
$sth->execute(array(
    ':member', $m_id
));

你确定建立了与SQL Server数据库的连接吗?是的,Sparta,如果我使用m_id=$m_id的常用方式而不是odbc驱动程序,你(或你尝试过)可以使用SQL驱动程序本身,然后使用
$c=new PDO(“sqlsrv:Server=localhost;database=testdb”,“UserName”,“Password”)