Why can't I use the prepared mysqli statement in php to query database data (bind parameters or bind results)? the project is in urgent need! What should I do?

Source: Internet
Author: User
Why can't I use the prepared mysqli statement in php to query database data (bind parameters or bind results)? the project is in urgent need! The code is as follows: PHPcode & lt ;? Php/* use mysqli extension to bind the result * // Create a server connection $ why can't mysql use the mysqli preparation statement in php to query data in the database (bind parameters or bind results), urgent project use!
The code is as follows:
PHP code
  
  Stmt_init (); // prepare the statement for execution $ stmt-> prepare ($ query); // execute the statement $ stmt-> execute (); // bind_result ($ name, $ pwd); // cyclically process the result and output the data while ($ stmt-> fetch ()) {printf ("% s, % s, % s
", $ Name, $ pwd);} // restore statement resource $ stmt-> close (); // close the connection $ mysqli-> close ();?>
What is the problem with this statement? I can directly add, delete, modify, and query the statement, but neither use the mysqli binding result nor the method for binding parameters. could you please help me, the company's internship will soon be used as a project, and it will be urgently used !!

------ Solution --------------------
Printf ("% s, % s, % s
", $ Name, $ pwd );???

A parameter is missing.
Or an extra formatted character.
------ Solution --------------------
Add one more placeholder. Don't you only have two parameters?
------ Solution --------------------
If one line of code is missing, you must temporarily store the query results for use.
For reference only:
PHP code
Function selectLink ($ oid) {$ SQL = "select o. oid, l. lid, c. cid, comName, comPrice, ordTime from mis_order o, mis_link l, mis_commodity c where o. oid = l. lid and c. cid = l. cid and o. oid =? "; $ Stmt = $ this-> mysqli-> prepare ($ SQL); $ stmt-> bind_param (" I ", $ oid); $ stmt-> execute (); $ stmt-> store_result (); $ stmt-> bind_result ($ oid, $ lid, $ cid, $ comName, $ comPrice, $ ordTime ); $ rows = $ stmt-> affected_rows; if ($ rows> 0) {$ arrLink = array (); while ($ stmt-> fetch ()) {$ arr = array ("oid" => $ oid, "lid" => $ lid, "cid" => $ cid, "comName" => $ comName, "comPrice" => $ comPrice, "ordTime" => $ ordTime); array _ Push ($ arrLink, $ arr);} return $ arrLink;} else {echo "an error occurred while querying order details!
";}}

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.