简体   繁体   English

PHP PDO Select查询未从数据库中选择行

[英]PHP PDO Select query not selecting rows from database

I am running this PDO query: 我正在运行此PDO查询:

$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$stmt->execute(array(':sequence' => $_GET["sequence"]));
$result = $stmt->fetch();

to select rows from a database but when i do a var_dump($smtm); 从数据库中选择行,但是当我做var_dump($ smtm);时 I get this result: 我得到这个结果:

object(PDOStatement)#2 (1) { ["queryString"]=> string(57) "SELECT * from billing_control where sequence = :sequence " }

I have ?sequence=178 on the end of my URL so it should be running the SQL: 我的URL末尾有?sequence=178 ,因此它应该运行SQL:

select * from billing_control where sequence = 178

Any ideas what I have got wrong? 任何想法我错了吗?

Try: 尝试:

$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$stmt->bindParam(':sequence', $_GET["sequence"])
$stmt->execute();

Another version would be: 另一个版本是:

$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = ? ");
$stmt->execute(array("%$_GET[sequence]%"));

Try this 尝试这个

$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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM