Why can't I execute this preprocessing statement? $ Mysqli = new mysqli ("localhost", "root", "123456", "xsphpdemo ");
If (mysqli_connect_errno ()){
Echo "connection failed
". Mysqli_connect_error ();
}
$ Stmt = $ mysqli-> prepare ("select id name price num desn from shop where id>? ");
$ Stmt-> bind_param ("I", $ id );
$ Stmt-> bind_result ($ id, $ name, $ price, $ num, $ desn );
$ Id = "10 ";
$ Stmt-> execute ();
$ Stmt-> store_result ();
While ($ stmt-> fetch ()){
Echo "$ id -- $ name -- $ price -- $ num -- $ desn
";
}
Echo $ stmt-> num_rows;
$ Stmt-> close ();
Run Var_dump ("select id name price num desn from shop where id>? ")
The Boolean value is false.
It seems that the $ mysqli-> prepare () statement is not successfully executed.
Reply to discussion (solution)
"Select 'id', 'name', 'price', 'num', 'dest' from shop where id>? "
Echo $ stmt-> error; is there an error message?
Echo $ stmt-> error; is there an error message?
No. I added quotation marks to the upstairs and added var_dump ($ stmt) to display the object, but an execution error turned into ------>
Echo $ stmt-> error; is there an error message?
No. I added quotation marks to the upstairs and added var_dump ($ stmt) to display the object, but an execution error turned into ------>
I have never used mysqli, but is this incorrect?
$stmt->bind_param("i",$id);
Should it be
$stmt->bind_param(1,$id);
Fields are not separated
$ Stmt = $ mysqli-> prepare ("select id, name, price, num, desn from shop where id>? ");