mysql_num_rows == 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I've run into a little barrier, and I'm wondering whether you have any
insights. I'm entering values into a MySQL database. Before running the
mysql_query, I'm checking if the value already exists (using mysql_num_rows
== 0).  If the value already exists in the database, the page will echo
"Username already exists" and it won't insert the user's new value. It runs
that far, and echoes the message accordingly. However, if the username is
new, and does not exist in the database, the query dies (without leaving a
mysql error).

I tried changing the Unique IDs in the database, but it doesn't seem to be
the issue. The syntax seems fine, as I used it for another similar page. Any
idea why it's dying?


        $check = mysql_query("SELECT * FROM user WHERE
user_name='$user_name'") or die ("Unable to query database:".mysql_error());

        $numrows = mysql_num_rows($check) or die ("Unable to search
database:".mysql_error());  -----> DIES HERE when a new value is entered. no
mysql_error msg.

        if ($numrows == 0)
        {

        }
           $alert = "Username already exists!";  ----> ECHOES correctly if
username already exists in the database (when mysql_num_rows != 0).

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux