0

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\registration\r­egistration.php on line 66

i already tried mysqli_error() and does not fix this problem

<html>
    <head>
        <title>Registration Form</title>
    </head>

<body>
<form method='post' action='registration.php'>
    <table width='400' border='5' align='center'>

        <tr>
        <td><h1>Registration Form</h1></td>

    </tr>

    <tr>
        <td>User Name:</td>
        <td><input type='text' name='name'/></td>
    </tr>

    <tr>
        <td>Password:</td>
        <td><input type='password' name='pass'/></td>
    </tr>
    <tr>
        <td>Email:</td>
        <td><input type='text' name='email'/></td>
    </tr>
    <tr>
        <td><input type='submit' name='submit' value='Sign Up'/></td>

    </tr>

    </table>
</form>  
</body>
</html>
<?php
mysql_connect("localhost","root","");
mysql_select_db("user_db"); 
    if(isset($_POST['submit'])){

    $user_name = $_POST['name'];
    $user_pass = $_POST['pass'];
    $user_email = $_POST['email'];

    if($user_name==''){
    echo "<script>alert('Please enter your Username')</script>";
    exit();
    }

    if($user_pass==''){
    echo "<script>alert('Please enter your password')</script>";
    exit();
    }

    if($user_email==''){
    echo "<script>alert('Please enter your email')</script>";
    exit();
    }

    $check_email="select *select* from users where 
    user_email='$user_email'";

    $run = mysql_query($check_email);

    if(mysql_num_rows($run)>0){

    echo"<script>alert('Email $user_email 
    is already exist in our databse, please try another 
    one')</script>";
    exit();
    }

    $query = "insert into users 
    (user_name,user_pass,user_email) values('
    $user_name','$user_pass','$user_email')";
    if(mysql_query($query)){

    echo "<script>alert('Registration 
    Successfull!')</script>";
    }

}



?>
3
Contributors
20
Replies
99
Views
4 Years
Discussion Span
Last Post by dean.ong.14
Featured Replies
0

Using mysqli_error () won't solve the problem. Rather, it'll aid in diagnosing it. What is the output received when you kill on mysqli_error? The PHP error you're receiving is due to a bad query, so the output of mysqli_error is critical.

0

You're using the mysql extension, so you should be using mysql_error() (without the i).

$check_email = "select * from users where user_email='$user_email'";
$run = mysql_query($check_email) or die(mysql_error());
0

`

if(mysql_query($query)) {

    echo "<script>alert('Registration 
    Successfull!')</script>";
    or
    die(mysql_error());

`

0
$result = mysql_query($query) or die(mysql_error());
if ($result)
{
    echo "<script>alert('Registration Successfull!')</script>";
}
0

it works sometimes only

$query = "insert into users 
    (users_name,users_pass,users_email) values('
    $users_name','$users_pass','$users_email')";

if(mysql_query($query)) {
    $result = mysql_query($query) or die(mysql_error());
    if ($result)
{
    echo "<script>alert('Registration Successfull!')</script>";
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.