<?php$dsn = "mysql:host=localhost;dbname=palace_banquet";$user = "root";$password = "";$dbh = new PDO($dsn, $user, $password);$pdo = new PDO("mysql:host=localhost;dbname=palace_banquet","root","");$pdo->query("SET NAMES utf8");$ysql="select n_account from noodles_member where n_username='{$uid}'";$yarr=$pdo->Query($ysql);$yarr[0][1];//总额这里$yarr[0][1]报错我用pdo链接数据库的
2 回答
慕斯王
TA贡献1864条经验 获得超2个赞
$pdo = new PDO('mysql:host=localhost;dbname=','root','');
$data = $pdo->query('SELECT * FROM `user`');
foreach($data as $v){
echo $v['id'];
}
正常情况下你还应该处理异常
try{
$pdo = new PDO('mysql:host=localhost;dbname=','root','');
$data = $pdo->query('SELECT * FROM `user`');
foreach($data as $v){
print_r($v);
}
}catch(PDOException $e){
}
- 2 回答
- 0 关注
- 126 浏览
添加回答
举报
0/150
提交
取消