Some of my problems are because I’ve used mysqli_fetch_all(), but I’m slightly mystified by some of the other issues.
For example here is my log in page: http://drtest.1x.biz/Login.php, which if I click submit, gives this error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /data/multiserv/users/1098223/projects/2448158/www/Login.php on line 11
Here is the code for the page:
[php]
<?php include "Includes/incConnection.php"; ?>
<?php
if (isset($_GET["Status"])) {$intStatus=funcStripText($_GET["Status"]);} else{$intStatus=0;}
if (isset($_POST["Submit"])){
$strUser = funcStripText($_POST["txtUser"]);
$strPass = funcStripText($_POST["txtPass"]);
if (($strUser != "")&&($strPass != "")){
$rsRow = mysqli_query($connBike, "SELECT UserID FROM tbl_Users WHERE Username='" . $strUser . "' AND UserPass='" . $strPass ."'");
if (mysqli_num_rows($rsRow)>0){ // <--- Line 11
$rsDetails = mysqli_fetch_assoc($rsRow);
mysqli_free_result($rsRow);
mysqli_close($connBike);
$_SESSION["UserID"] = $rsDetails["UserID"];
$intStatus = 1;
}
else{
$intStatus = 2;
}
}
}
?> [/php]
And here’s the code for the included file:
[php]
<?php
// Create connection
$connBike=mysqli_connect("host","user","pasword","db_bike"); //Local
// Check connection
if (mysqli_connect_errno($connBike)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
function funcStripText($strText){
if (is_numeric($strText)==false){
$arrBadWords = array("db_", "tbl_", ";", "--", "({", "/*", "xp_", "dt_", "varchar");
$strText = str_ireplace($arrBadWords, "", $strText);
$strText = str_replace("'", "''", $strText);
$strText = str_replace("<", "<", $strText);
$strText = str_replace(">", ">", $strText);
}
return $strText;
}
setlocale(LC_ALL, "en_GB");
session_start();
?>
[/php]