douxiegan6468 2014-04-09 20:21
浏览 29

PDO没有参数绑定sql错误

<?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 } } ?>

this is the code i have at present so please help me guys ?????

  • 写回答

1条回答 默认 最新

  • douhuo1738 2014-04-09 20:25
    关注

    You have a placeholder in your query named ":john", this means that you have to fill this placeholder with a correct value, before proceeding, using the "bindParam()" method of your PDO instance.

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

报告相同问题?

悬赏问题

  • ¥15 请提供一个符合要求的网页链接。
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码