Dies ist mein Code: 1) der Verbindungscode 2) die Login-SeiteIch habe einen Code MySQL und ich in eine Krise bin vor 'mysqli_num_rows() erwartet 1 Parameter MySQLi_Result, string gegeben werden'
<?php
ini_set("display_errors",1);
class connection //create a class for make connection
{
var $host = "localhost";
var $username = "root";
var $password = "";
var $database = "myDb";
var $myconn;
var $select;
var $query;
function database() //create a function for connect to database
{
$conn = mysqli_connect($this->host,$this->username,$this->password);
if(!$conn) // testing the connection
{
die ("Cannot connect to the database");
}
else
{
$this->myconn = $conn;
}
mysqli_select_db($this->myconn,$this->database); //use php inbuil function for select database
if(mysqli_error($this->myconn)) //if error occured display the error message\\
{
echo "Cannot find the database " . $this->database;
}
return $this->myconn;
}
function query($select)
{
$this->query= mysqli_query($this->myconn,$select)or die(mysqli_error($this->myconn));
}
function fetchQuery()
{
return mysqli_fetch_array($this->query);
}
function closeConnection() //close the connection
{
mysqli_close($this->myconn);
}
}
?>
und eine Seite, wo ich es handhabe.
<?php
$connection = new connection();
$connection->database();
if(isset($_POST['submit']))
{
$user = $_POST['name'];
$pass = $_POST['password'];
$select = "SELECT * From tab_user where txt_uname ='$user' and txt_pass ='$pass' ";
$result = $connection->query($select);
$count = mysqli_num_rows($result);
if($count>0)
{
$row = $connection->fetchQuery();
$name = $row['txt_full_name'];
echo $name;
$connection->closeConnection();
}
else
{
echo 'Wrong Inputs.';
}
}
?>
<form method="post">
<input type="text" name="name">
<input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>
Ich bin ein Problem "mysqli_num_rows() 1 erwartet Parameter MySQLi_Result, string gegeben werden" gegenüber. wie kann ich es lösen. Bitte helfen Sie. Vielen Dank !!
Treten immer noch Probleme. –