我正在运行此PDO查询:
$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$stmt->execute(array(':sequence' => $_GET["sequence"]));
$result = $stmt->fetch();
从数据库中选择行,但是当我执行var_dump($ smtm)时;我得到了这个结果:
object(PDOStatement)#2 (1) { ["queryString"]=> string(57) "SELECT * from billing_control where sequence = :sequence " }
我的网址末尾有?sequence=178
所以它应该运行SQL:
select * from billing_control where sequence = 178
任何想法我的错误?
答案 0 :(得分:0)
尝试:
$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$stmt->bindParam(':sequence', $_GET["sequence"])
$stmt->execute();
另一个版本是:
$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = ? ");
$stmt->execute(array("%$_GET[sequence]%"));
答案 1 :(得分:0)
试试这个
$query = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$query->bindParam(':sequence', $_GET["sequence"], PDO::PARAM_STR, 255); //I assume that sequence data is string
$result = $query->execute();