Did someone encounter Mysqli's Fetch_assoc () method error? Solution Solutions

Source: Internet
Author: User
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;  }
  • 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.