这个php5 的pdo哪里出错啦?? $e->getMessage();// Connect to an ODBC database using driverinvocation这里怎么都断开了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php// Connect to an ODBC database using driver invocation$dsn = 'mysql:dbname=test;host=127.0.0.1';$user = 'root';$password = 'root';try { $dbh = new PDO($dsn, $user, $password);} catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage();}$stmp = $dbh->prepare("select * from adeg_info");if($stmp->execute()){ while($row = $stmt->fetch()){ print_r($row); }}?>直接用fetchAll()取出全部记录然后循环处理数组,要比在循环中fetch()要快很多况且当你向模板引擎提供数据时也只需一个数组就解决问题 $row = stmt->fetch())加多一个$ if($stmp->execute()){while($row = $stmt->fetch()){//***********print_r($row);}}?> 使用百度的UEditor,在前端用jquery获取不了textarea的内容 PHP登陆表单验证问题 存百度-免费无限全能空间-----免费 稳定 快速 php做个动态树 web 开发。 url重写中末尾的$1是什么意思 AMFPHP 1.9显示错误 在PHP中如果调用MySQL中已经写好的存储过程? 一个查看OICQ是不是在线 的程序 XAMPP 不编译 远程读取疑问:常用的远程读取方法是哪些? 喜欢玩sql注入的进来看看...
// Connect to an ODBC database using driver invocation
$dsn = 'mysql:dbname=test;host=127.0.0.1';
$user = 'root';
$password = 'root';try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}$stmp = $dbh->prepare("select * from adeg_info");
if($stmp->execute()){
while($row = $stmt->fetch()){
print_r($row);
}
}
?>直接用fetchAll()取出全部记录然后循环处理数组,要比在循环中fetch()要快很多
况且当你向模板引擎提供数据时也只需一个数组就解决问题
加多一个$
while($row = $stmt->fetch()){//***********
print_r($row);
}
}
?>