This question already has an answer here:
What I am trying to do:
Trying to create a register php script that works. Basically I need new records in my table.
Problem:
I am learning php and trying to find out how to solve, after loads of fixing, this last error message which I absolutely dont understand.
What I tried:
I set up the database and wrote the script. After that I encountered 13 errors from which I only fixed 12. The remaining one really gives me a hard time. I know it has something to do with mysqli_result but no idea how to implement it. I did try this:
$amount = mysqli_num_rows(mysqli_result, $result);
Error message:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given on line 22
<?php
$connection = mysqli_connect("localhost", "root", "", "project")
or die("cant connect");
$name = $_POST["name"];
$email = $_POST["email"];
$age = $_POST["age"];
$about = $_POST["about"];
$occupation = $_POST["occupation"];
$special_talent = $_POST["special_talent"];
$password = $_POST["password"];
$repeat_password = $_POST["repeat_password"];
if($password != $repeat_password OR $name == "" OR $password == "")
{
echo "Error";
exit;
}
$result = mysqli_query($connection, "SELECT id FROM members WHERE name, email LIKE '$name', '$email'");
$amount = mysqli_num_rows($result);
if($amount == 0)
{
$record = "INSERT INTO members (name, email, age, about, occupation, special_talent, password, repeat_password) VALUES ('$name', '$email', '$age', '$about', '$occupation', '$special_talent', '$password', '$repeat_password')";
$register = mysqli_query($connection, $record);
if($register == true)
{
echo "Congratulations $name, you are now a Member!</a>";
}
else
{
echo "Unfortunately the registration failed. Try again please.</a>";
}
}
else
{
echo "Username already in use";
}
?>
</div>