Is there an error in the fetch_assoc () method of mysqli? The configuration is phpnow5.1.6: windowsXP + php5.2.14 + apache2.2.6 + MySQL5.1.50. when fetch_assoc () of the mysqli class is used, Apache seems to be out of service. See the following code: PHPcodewhi does someone encounter an error in the fetch_assoc () method of mysqli?
The configuration is phpnow5.1.6: windowsXP + php5.2.14 + apache2.2.6 + MySQL5.1.50
When fetch_assoc () of the mysqli class is used, Apache seems to have been suspended. 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 prompts that the page cannot be displayed. FF prompts that the connection to the server is reset when the page is loaded.
If the above code is removed, it will return to normal.
If you replace the array associated with fetch_assoc with the index array of fetch_row (), you can replace $ row ['firstname'] with $ row [0.
But sometimes the code becomes unclear, so is there a solution to help you ?!
I 've been google online for a long time and found that few people encounter such problems. even if there are, they just write errors or something, which is not suitable for solving this problem.
------ Solution --------------------
Use the $ rs-> fetch_array method.
------ Solution --------------------
Just add the parameter with fetch_array (): MYSQLI_ASSOC [association], MYSQLI_NUM [number], MYSQLI_BOTH [all]
PHP code
Query ($ query);/* numeric array */$ row = $ result-> fetch_array (MYSQLI_NUM); printf ("% s (% s) \ n ", $ row [0], $ row [1]);/* associative array */$ row = $ result-> fetch_array (MYSQLI_ASSOC); printf ("% s (% s) \ n ", $ row [" Name "], $ row [" CountryCode "]); /* associative and numeric array */$ row = $ result-> fetch_array (MYSQLI_BOTH); printf ("% s (% s) \ n", $ row [0], $ row ["CountryCode"]);/* free result set */$ result-> close ();/* Close connection */$ mysqli-> close ();?>
------ Solution --------------------
No error message?
It seems that the error display function is not enabled.
------ Solution --------------------
It can only be that your associated fields are not matched with those in the database.
There is no way. use pre-compilation for processing:
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 () {// extract the file name from the path and convert it to the relative path $ movImg = ".. /.. /images /". basename ($ movImg); // capture the file name $ arrStr = explode (". ", basename ($ movPlay); $ movPlay = ".. /.. /videos /". $ arrStr [0]; $ arr = array ("mid" => $ mid, "movName" => $ movName, "movType" => $ movType, "movStar" => $ movStar, "movImg" => $ movImg, "movPlay" => $ movPlay, "director" => $ director, "producter" => $ producter); array_push ($ arrMovie, $ arr);} return $ arrMovie ;}