Hi guys!
I have just written a code to gather some data form a table of a MySQL Database...
But I have just faced a problem...
When I run the code, I receive this error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\fwe.php on line 25
Heres my code:
<?php
header('Content-Type: text/html; charset=utf-8');
$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "azmoon";
//if (!isset($GET['username']) || !isset($GET['password']) || !isset($GET['email']) ){
// die ("field does not exit !") ;
//}
$user = $GET['username'] ;
$pass = $GET['password'] ;
/*$ema = $GET['email'];
*/
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
mysqli_set_charset($conn,"utf8");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT username,password,email,pich,field,farsirotbe,farsirotbezir,arabipercent,arabigrade,arabirotbe,arabirotbezir,dinipercent,dinigrade,dinirotbe,dinirotbezir,zabanpercent,zabangrade,zabanrotbe,zabanrotbezir,riazipercent,riazigrade,riazirotbe,riazirotbezir,zistpercent,zistgrade,zistrotbe,zistrotbezir,fizikpercent,fizikgrade,fizikrotbe,fizikrotbezir,shimipercent,shimigrade,shimirotbe,shimirotbezir,rotbekol,rotbekolzir FROM tbl1
WHERE username='$user'and password='$pass' ";
$res = mysqli_query($conn, $sql);
if (mysqli_num_rows($res)>0) {
// output data of each row
while($row = mysqli_fetch_assoc($res)) {
echo "" . $row["pich"]. "|" . $row["password"]. "|" . $row["email"]. "|". $row["field"]. "|" . $row["farsirotbe"]. "|" . $row["farsirotbezir"]. "|" . $row["arabipercent"]. "|" . $row["arabigrade"]. "|" . $row["arabirotbe"]. "|" . $row["arabirotbezir"]. "|" . $row["riazipercent"]. "|" . $row["riazigrade"]. "|" . $row["riazirotbe"]. "|" . $row["riazirotbezir"]. "|" . $row["fizikpercent"]. "|" . $row["fizikgrade"]. "|" . $row["fizikrotbe"]. "|" . $row["fizikrotbezir"]. "|" . $row["shimipercent"]."|" . $row["shimigrade"]. "|" . $row["shimirotbe"]. "|" . $row["shimirotbezir"]."|" . $row["dinipercent"]. "|" . $row["dinigrade"]. "|" . $row["dinirotbe"]. "|" . $row["dinirotbezir"]. "|" . $row["zabanpercent"]. "|" . $row["zabangrade"]. "|" . $row["zabanrotbe"]. "|" . $row["zabanrotbezir"]. "|" . $row["zistpercent"]."|" . $row["zistgrade"]. "|" . $row["zistrotbe"]. "|" . $row["zistrotbezir"]. "|" . $row["rotbekol"]. "|" . $row["rotbekolzir"]. "";
}
} else {
echo "0";
}
$conn->close();
?>`
And also here is line 25 that was mentioned:
if (mysqli_num_rows($res)>0) {
P.S: I call the required data by entering this URL: "127.0.0.1/fwe.php?username=1411612090&password=1161"
Would you guys help me?
I am a beginner and I have aimed high for my first official job....
Also I am reaching the deadline :-|
I really need you guys to join this discussion!