0
    $name1 = $_POST['name1'];
    $lname = $_POST['lname'];
    $uname = $_POST['uname'];
    $email1 = $email1;
    $email2 = $email2;
    $pass1 = $pass1;
    $pass2 = $pass2;

    $pass1 = md5($pass1);

    $sql = "SELECT  * FROM users WHERE uname = $uname";
    if(mysql_num_rows($sql) > 0) {
        echo "Sorry, that user already exists";
        exit();

        }

Warning: mysql_num_rows() expects parameter 1 to be resource,given in /nas/students/unix/public_html/dsa1/register.php on line 27

ST3
  • 8,410
  • 3
  • 64
  • 90
  • 1
    This is not a question in its current form. But I suggest you take a look at the standard PHP documentation and preferably skip the inherently unsafe [`mysql_*`](http://php.net/mysqli) family of functions in favor of [`mysqli_*`](http://php.net/mysqli) or even [`PDO::*`](http://php.net/PDO). Please *do not ever* blindly paste user provided data into any query, unless you are actually on a quest for SQL injection hacks. – Bart Feb 17 '14 at 20:13

2 Answers2

0

Surely the documentation might help:

int mysql_num_rows ( resource $result )

Retrieves the number of rows from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set.

A resource is something different than an SQL query. In this case a resource is what the PHP MySQL library passes around to refer to a statement that's already been run.

You need to pass the SQL statement to mysql_query first to run it. mysql_num_rows will then take the result of that function call and tell you how many rows are in it.

Steve Howard
  • 6,359
  • 1
  • 25
  • 37
0

You should do the query and then num rows

$result = mysql_query($stringQuery $link);
$total = mysql_num_rows($result);
pedritin
  • 47
  • 2
  • 10