<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once("set.php");
function fetchinfo($rowname, $tablename, $key, $val, $db)
{
$stmt = $db->prepare('SELECT ? FROM ? WHERE ? = ?');
$stmt->execute([$rowname, $tablename, $key, $val]);
$row = $stmt->fetch();
return $row[$rowname];
}
echo fetchinfo("name","users","steamid","76561198159854902", $pdo);
?>
输出:
set.php正在运行
致命错误:未捕获PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法出错;检查与您的MariaDB服务器版本对应的手册,以便在'附近使用正确的语法?在哪里? =?'在C:\ xampp \ htdocs \ index.php的第1行:11堆栈跟踪:#0 C:\ xampp \ htdocs \ index.php(11):PDO-&gt; prepare('SELECT?FROM?...' )#1 C:\ xampp \ htdocs \ index.php(20):fetchinfo('name','users','steamid','765611981598549 ...',Object(PDO))#2 {main}引入第11行的C:\ xampp \ htdocs \ index.php