Issue with Mysql_num_rows php/mysql

rodife

I'm trying to get email validation working. So my PHP code is firing off a query that that should return if it has any rows with the matching email. If 1 row is returned it then returns an error message, that I have else where in my code and sets my valid boolean to false.

However, I'm getting this error "Warning: mysql_num_rows() expects parameter 1 to be resource, object given in"

I think I'm using mysql_num_rows() wrong, but I'm new to php/mysql :( I can't seem to figure it out.

Here's the relevant sections of my code.

$conn = @mysqli_connect("server","user","pass","database");

if (!$conn) {
    // Displays an error message
    echo "<p>Database connection failure</p>";

////

        $sql_table="Customer";
        $query="SELECT * FROM $sql_table WHERE EMAIL = '$email'";
        $result = mysqli_query($conn, $query);

            if (mysql_num_rows($result) >= 1) { //<-- Offending line

                                $takenErr = "Email already taken ";
                                $valid = false; }

        if (!$result) {
            echo "<p> something is wrong with ", $query, "<p>";
            }

Thanks guys/gals! :).

tomexsans

You can use

$row_cnt = $result->num_rows;

or

mysqli_num_rows($result);

you are using mysqli driver so use it at all times.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related