So, I am a total n00b at PHP (and back-end programming in general), but I never the less decided I wanted to build a functioning database that users could search client-side as th final project for my first web dev class.
Anyway, I made my site and database on a localhost, and though it took a while, I got everything functioning perfectly. When I tried to move it to my webhost, however, everything started breaking because, previously unbeknownst to me, the webhost is using PHP 5.2. I've been able to rig everything else with some functioning solutions of dubious security (I know, I know, but I'm desperate, and there's only fake data on here anyway), but the one thing I can't find a fix for is the mysqli_fetch_all(). I get a Call to undefined function mysqli_fetch_all() error.
I'm using it for my search functionality: when you search for a user, the function takes all the rows with matching information and puts it in an array, and at the end, all the result arrays are merged into a single array that is returned. I did it this way so that search criteria that is not entered would be ignored and not return an error (NULL has been the bane of my existence this entire project).
The site can be viewed at http://webinfofinal.webatu.com/profiles.html so you see what I'm working with and the code is below. Any suggestions? I've tried other fetch functions, but they only return the first matching row.
if ($firstName != null){
$result2 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where firstName = '$firstName' ");
$query2 = mysqli_fetch_all($result2,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query2);
}
if ($lastName != null){
$result3 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where lastName = '$lastName' ");
$query3 = mysqli_fetch_all($result3,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query3);
}
if ($eMail != null){
$result4 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where eMail = '$eMail' ");
$query4 = mysqli_fetch_all($result4,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query4);
}
if ($age != null){
$result5 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where age = '$age' ");
$query5 = mysqli_fetch_all($result5,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query5);
}
if ($classification != null){
$result6 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where classification = '$classification' ");
$query6 = mysqli_fetch_all($result6,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query6);
}
if ($major != null){
$result7 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where major = '$major' ");
$query7 = mysqli_fetch_all($result7,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query7);
}
if ($faveAnimes != null){
$result8 = mysqli_query($con, "SELECT displayName , firstName , lastName , eMail , age , classification , major , faveAnimes FROM a2097702_fac.members where faveAnimes = '$faveAnimes' ");
$query8 = mysqli_fetch_all($result8,MYSQLI_ASSOC);
$search = array_merge_recursive($search, $query8);
}
if ($search != null){
echo "<html>";
echo "<head>";
echo"<title> Anime Club Search Results | Web Info Final Project </title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"webinfofinal.css\">";
echo "</head>";
echo "<div class=\"content\" style=\"width:50%; margin-left:-20%;\">";
echo "<div class=\"header\">";
echo "<p></p><p>Your search results are below. </p>";
echo "</div>";
echo "<pre>";
print_r($search);
echo "</pre>";
echo "<p>End of results. <a href=\"profiles.html\">Search again?</a></p>";
echo "<a href=\"login.html\"><input type='button' value='Update My Profile' id='updateProfile'></a>";
echo "<a href=\"logout.php\"><input type='button' value='Log Out' id='logout'></a>";
echo "</div>";
echo "</html>";
}