php pdo 错误
<?phpheader("Content-type:text/html;charset=utf-8");$url="mysql:host=localhost;dbname...
<?php
header("Content-type: text/html; charset=utf-8");
$url = "mysql:host=localhost;dbname=test";
$user = "root";
$pwd = "root";
$conn = new PDO($url,$user,$pwd);
$conn->query("set names utf8");
function d1($sql){
$st = $conn->query($sql);
$result = $st->fetch();
echo $result[0];
}
报错:Call to a member function query() on a non-object in 这一行$st = $conn->query($sql);
PDO初学,应该怎么修改 展开
header("Content-type: text/html; charset=utf-8");
$url = "mysql:host=localhost;dbname=test";
$user = "root";
$pwd = "root";
$conn = new PDO($url,$user,$pwd);
$conn->query("set names utf8");
function d1($sql){
$st = $conn->query($sql);
$result = $st->fetch();
echo $result[0];
}
报错:Call to a member function query() on a non-object in 这一行$st = $conn->query($sql);
PDO初学,应该怎么修改 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询