Why can't I execute this preprocessing statement?

Source: Internet
Author: User
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>? ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.