dpmrakfbx820320638 2013-07-24 18:00
浏览 35

MySQLi绑定参数错误[关闭]

My code generates an Call to a member function bind_param() on a non-object error. When I perform a var dump the result is bool(false). It appears that PHP doesn't think the $statement variable is an object. I'm kind of new to this so any help would be appreciated. I've also tried replacing the $id variable value with a string with no luck.

<?php
$con=new MySQLi("localhost","root","mysql","tinymce");

$statment = $con->prepare("SELECT * FROM 'content' WHERE 'id'=?");

$id=1;

$statement->bind_param('i', $id);

$statement->execute();



$con->close();
?> 
  • 写回答

2条回答 默认 最新

  • dongluzhi5208 2013-07-24 18:03
    关注

    This is the first thing I noticed. Use back ticks not single quotes:

    $statment = $con->prepare("SELECT * FROM `content` WHERE `id`=?");
    

    Other problems noticed:

    // Haven't tested this but it could be case sensitive, use `mysqli` not `MYSQLi`
    $con=new mysqli("localhost","root","mysql","tinymce");  
    
    // Typo here?  it should be `$statement = ` not `$statment` as you're using `$statement` in rest of your code.
    $statement = $con->prepare("SELECT * FROM `content` WHERE `id`=?");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号