mysqli bind param问题:在布尔值上调用成员函数bind_param()

I want to update a table but i keep getting the error: Call to a member function bind_param() on boolean

What am i doing wrong? In my db setting looks like this:

  '{"name":"Product Slider","product_name":"","product":["240","375","5555"],"limit":"5","width":"600","height":"400","loop":"1","auto":"1","pager":"1","pause":"3000","speed":"800","status":"1"}'

My attempt to update:

 $sliderSql=$con->prepare("UPDATE oc_module SET setting = '{'name':'Product Slider','product_name':'','product':[?],'limit':'5','width':'600','height':'400','loop':'1','auto':'1','pager':'1','pause':'3000','speed':'800','status':'1'}' WHERE oc_module.module_id = 95");

$param="'".$calcSlider[0]."','".$laptopSlider[0]."','".$serverSlider[0]."'";

$sliderSql->bind_param("s",$param);

The quotes in your SQL are wrong. The single quotes in your JSON are terminating the string. Quotes in JSON have to be double quotes. Since they're embedded inside a string literal, you need to escape them.

$sliderSql=$con->prepare("UPDATE oc_module SET setting = '{\"name\":\"Product Slider\",\"product_name\":\"\",\"product\":[?],\"limit\":\"5\",\"width\":\"600\",\"height\":\"400\",\"loop\":\"1\",\"auto\":\"1\",\"pager\":\"1\",\"pause\":\"3000\",\"speed\":\"800\",\"status\":\"1\"}' WHERE oc_module.module_id = 95");

But there's another problem. You can't put a ? parameter inside a string literal -- they can only be used where a value expression is allowed.

It would be easier if you used a separate variable, which you converted to JSON using json_encode().

$setting = json_encode(array(
     "name" => "Product Slider",
     "product_name" => "",
     "product" => array($calcSlider[0], $laptopSlider[0], $serverSlider[0]),
     "limit" => "5",
     "width" => "600",
     "height" => "400",
     "loop" => "1",
     "auto" => "1",
     "pager" => "1",
     "pause" => "3000",
     "speed" => "800",
     "status" => "1"));
$sliderSql = $con->prepare("UPDATE oc_module SET setting = ?");
$sliderSql->bind_param("s", $setting);