Why can't I use MYSQLI's prepared statement in PHP to query the data in the database (binding parameters or binding results), the project urgently!
The code is as follows:
PHP Code
Stmt_init (); Prepares statements for execution $stmt->prepare ($query); Execute statement $stmt->execute (); Binding result Parameters $stmt->bind_result ($name, $pwd); Loop through the results and output the data while ($stmt->fetch ()) {
", $name, $pwd); } Recovery Statement Resource $stmt->close (); Close connection $mysqli->close ();? >
What's the problem with this statement? I directly do the additions and deletions can be, but whether it is the use of mysqli binding results or the method of binding parameters are not, for the hero guidance Ah, the company will soon use it to do the project, emergency emergencies!!
------Solution--------------------
printf ("%s,%s,%s
", $name, $pwd);???
One parameter is missing.
or one more format character,
------Solution--------------------
One more placeholder. Don't you only have two parameters?
------Solution--------------------
One line of code is missing, and the query results can be stored temporarily 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, Time); $rows = $stmt->affected_rows; if ($rows > 0) {$arrLink = array (); while ($stmt->fetch ()) {$arr = Array ("oid" = = $oid, "lid" => ; $lid, "cid" = $cid, "Comname" and "$comName," Comprice "=> ; $comPrice, "ordtime" = Time); Array_push ($arrLink, $arr); } return $arrLink; }else{echo "Query Order Details failed!
"; } }