Jump to content

num rows


marklarah

Recommended Posts

<?php
include_once 'top.php';





if ($_POST['u1'] == $_POST['u2'] && $_POST['e1'] == $_POST['e2'] && $_POST['p1'] == $_POST['p2']) { 

if ($_POST['u1'] == ''){
echo "No.";
exit;
}

if ($_POST['e1'] == ''){
echo "No.";
exit;
}

if ($_POST['p1'] == ''){
echo "No.";
exit;
}


$sql = "select * from users where username='" . $_POST['u1'] . "'"; 
$result = mysql_query($sql); 


$sql2 = "select * from users where email='" . $_POST['e1'] . "'"; 
$result2 = mysql_query($sql2); 

if (mysql_num_rows($result) >= 1) { 
$err =  "Username, ";
}else{
$err =  "";
}

if (mysql_num_rows($result2) >= 1) { 
$err2 =  "Email ";
} else {
$err2 = "";
}



if (mysql_num_rows($result) >= 1 || mysql_num_rows($result2) >= 1) { 

echo '<b>Error: </b>'; echo $err; echo $err2; echo 'already in use - <a href="register.php">try again</a>.';
} else { 
$username = $_POST['u1']; 
$pass = md5($_POST['p1']); 
$email = $_POST['e1']; 


$usernamee = htmlentities($username);
$emaile =  htmlentities($email);


$sql = "INSERT INTO users (ID, username, password) VALUES (NULL, '$usernamee', '$pass')";
mysql_query($sql) or die('Registration failed');



?>
You successfully registered. Now proceeding to login.
<meta http-equiv="REFRESH" content="3;url=experiment login.php">

<?php
}
}else{
echo '<b>Error:</b> You filled the form in incorrectly - <a href="register.php">try again</a>.';
}
?>

 

When registering:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/disturbe/public_html/reging.php on line 39

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/disturbe/public_html/reging.php on line 47

You successfully registered. Now proceeding to login.

 

Can anyone help?

 

 

Link to comment
Share on other sites

I am not the greatest person with mysql, but it looks like your mysql_num_results is returning a 0 count. Meaning, its not finding any results. I would add something that would tell the server what to do in the event that no results are found. It looks like when someone tries to register, it verifies that the username and email are not in use. If it find none, it returns a result of 0 which is causing your error.

 

Also, adding the die function will halt the program from continuing on.

 

Here is one way that you might be able to work around it:

 

if (mysql_num_rows($result) >= 1)

{

die("That username is already in use.");

}

 

This won't completely fix the problem, but it should give you a general direction.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.