Last active
September 25, 2020 21:21
-
-
Save jxxe/52105f9adbdedbfbe8af8a52c0b540b9 to your computer and use it in GitHub Desktop.
Not all servers run the latest version of PHP or have enabled all the packages. This small replacement saved me a lot of frustration with my web host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Replace | |
$data = $query->fetch_all(MYSQLI_ASSOC); | |
// With | |
$rows = []; | |
while ( $row = mysqli_fetch_assoc($query) ) { | |
$rows[] = $row; | |
} | |
$data = $rows; | |
// Or Even, Define | |
function fetch_assoc($query) { | |
$rows = []; | |
while ( $row = mysqli_fetch_assoc($query) ) { | |
$rows[] = $row; | |
} | |
return $rows; | |
} | |
// And Use | |
$data = fetch_assoc($query); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment