Jump to content

Problem in using function mysql_num_rows


PURU

Recommended Posts

hey

 

I HAVE BEEN USING PHP DEV 5.I want to verify username and password with database using function mysql_num_rows but every time i use this function it show s error.So can you help me out.My code is given below.

 

$name = $_POST['name'];

$email = $_POST['email'];   

$username = $_POST['username'];

$password = md5($_POST['password']);

 

 

checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

 

$username_exist = mysql_num_rows($checkuser);

 

if($username_exist > 0){

    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";

    unset($username);

    include 'register.html';

    exit();

}

 

 

 

 

 

please use the following code and copy/paste the EXACT error displayed:

 

<?php
$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$username = mysql_real_escape_string($_POST['username']);
$password = md5($_POST['password']);

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'")
  or die(mysql_error());

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.