gpt4 book ai didi

php - PDO无参数绑定(bind)sql错误

转载 作者:行者123 更新时间:2023-11-29 08:04:41 24 4
gpt4 key购买 nike

<?php include 'connection.php'; 
session_start();
$sqls ="SELECT * FROM markus WHERE user= :c AND id=:id";
$result= $handle->prepare($sqls);
$result->bindParam(':c',$_COOKIE['john'],PDO::PARAM_STR);
$result->bindParam(':id', $_POST['id'],PDO::PARAM_INT);
$resullt execute ();
$row = $result->fetchAll(PDO::FETCH_ASSOC);
if(!($row)){– if (!isset($_POST['submit']) && $_POST['r'] <= 5 )
{ $sql_1 = "INSERT INTO markus (bo,us,r,rng) VALUES(:bo,:us,:r,:rng)"; $query = $handle->prepare ($sql_1); $params = array(':bo'=> $_POST['bo'],':us'=> $_POST['us'],':r'=> $_POST ['r'],':rng'=> $_POST['rng']);
$query -> execute($params); echo success }
else { echo nope } } ?>

这是我目前拥有的代码所以请帮助我吗????

最佳答案

您的查询中有一个名为“:john”的占位符,这意味着您必须使用 PDO 实例的“bindParam()”方法使用正确的值填充此占位符,然后才能继续。

$sqls =$handle->prepare("SELECT * FROM john WHERE user= :cookieJohn AND book_id=:john");
//This lines right under here
$sqls->bindParam(':cookieJohn',$_COOKIE['john']);
$sqls->bindValue(':john',1,PDO::PARAM_INT);
$sqls->execute();
$row = $sqls -> fetch();

关于php - PDO无参数绑定(bind)sql错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22973169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com