Did someone encounter Mysqli's Fetch_assoc () method error?
Configuration is Phpnow5.1.6:windowsxp + php5.2.14 + apache2.2.6 + MySQL5.1.50
When using the Mysqli class of Fetch_assoc (), Apache seems to be having a break. See the following code:
PHP Code
while ($row = $rs->fetch_assoc ()) {echo ""; echo "". $row [' FirstName ']. ""; echo "". $row [' LastName ']. ""; echo "". $row [' Age ']. ""; echo "". $row [' Hometown ']. ""; echo "". $row [' Job ']. ""; echo "";}
IE prompt cannot display the page, FF prompts to load the page when the connection to the server is reset.
If you remove the above code, it will return to normal.
If you replace the FETCH_ASSOC associative array with an indexed array of Fetch_row (), it is OK to change the $row[' FirstName ' to $row[0].
But sometimes this code will become unclear, so come up to help everyone there is no solution?!
I have been on the internet for a long time, found that very few people have encountered such problems, even if there is only a written error, not suitable to solve my problem.
------Solution--------------------
Use the $rs->fetch_array method.
------Solution--------------------
With Fetch_array () plus parameters: Mysqli_assoc[Association], mysqli_num[number], mysqli_both[all]
PHP Code
Query ($query);/* Numeric array */$row = $result->fetch_array (mysqli_num);p rintf ("%s (%s) \ n", $row [0], $row [1]);/* Associative array */$row = $result->fetch_array (MYSQLI_ASSOC);p rintf ("%s (%s) \ n", $row ["Name"], $row ["CountryCode" ]);/* associative and numeric array */$row = $result->fetch_array (mysqli_both);p rintf ("%s (%s) \ n", $row [0], $row ["Cou Ntrycode "]);/* FREE result set */$result->close ();/* Close connection */$mysqli->close (); >
------Solution--------------------
No error message?
Looks like it didn't turn on the error display function
------Solution--------------------
That can only be your correlation field does not correspond to the database.
There's really no way to do it with precompilation:
PHP Code
$sql = "Select Mid,movname,movtype,movstar,movimg,movplay,director,producter from Mov_film"; $stmt = $this->mysqli->prepare ($sql); $stmt->execute (); $stmt->store_result (); $stmt->bind_result ($mid, $movName, $movType, $movStar, $MOVIMG, $movPlay, $director, $producter); $rows = $stmt->affected_rows; if ($rows > 0) {$arrMovie = array (); while ($stmt->fetch ()) {//takes the file name out of the path and converts it to a relative path $MOVIMG = ". /.. /images/". basename ($MOVIMG); Intercept file name $arrStr = Explode (".", BaseName ($movPlay)); $movPlay = ". /.. /videos/". $arrStr [0]; $arr = Array ("mid" = = $mid, "movname" = = $movName, "Movtyp E "+ $movType," Movstar "and $movStar," movimg "and $MOVIMG, "Movplay" = $movPlay, "director" and "$dIrector, "producter" = $producter); Array_push ($arrMovie, $arr); } return $arrMovie; }