Jump to content

Fold in Mysql num rows


maxrjc

Recommended Posts

mysql_num_rows($return);  will give you the number of rows that will be returned by whatever SQL query you have in $return.

 

according to the manual here: mysql_num_rows

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. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use mysql_affected_rows().

mysql_num_rows($return);  will give you the number of rows that will be returned by whatever SQL query you have in $return.

 

according to the manual here: mysql_num_rows

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. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use mysql_affected_rows().

 

 

Now hes sayes:

 

 

Wrong parameter count for mysql_num_rows() in /home/a5078111/public_html/registerpage.html on line 146

 

Where is your code? Please, give it us.  8)

 

This is the code:

 

Als iemand nieuw zich lid maakt wordt deze rang 1 gegeven dus member om iemand andere rechten te geven moet je naar de db gaan of zelf een scriptje maken. :P

 

<?
session_start();
?>
<font face=verdana size=1>

<?
if($_SESSION['login'] == "true"){
   print " You have allready an account.";//because your logged in stupid
}

include('connect.inc.php');
if(!isset($_REQUEST['submit'])){
?>
<form method=post acion=""<? $_SERVER['PHP_SELF'] ?>"">
<table>
   <tr>
      <td>
         <font face=verdana size=1>Username:
      </td>
      <td>
         <input type="text" name="name" maxlength="15">
      </td>
   </tr>
   <tr>
      <td>
         <font face=verdana size=1>Password:
      </td>
      <td>
         <input type="password" name="pass1">
      </td>
   </tr>
   <tr>
      <td>
         <font face=verdana size=1>Confirm:
      </td>
      <td>
            <input type="password" name="pass2">
      </td>
   </tr>
   <tr>
      <td>
         <input type="submit" value=submit name="submit">
      </td>
      <td>
         <input type="reset">
      </td>
   </tr>
</table>
</form>
<?php
}else{
   //request everything
   $dead = "false";//We make 'dead' if some fields are not filled in don't check for pass and name in db.
   $message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>";
   $username = $_POST['name'];
   $pass1 = $_POST['pass1'];
   $pass2 = $_POST['pass2'];
   $ip = $_SERVER['REMOTE_ADDR'];
   $status = "1";//1 member, 2,co-admin 3, admin
   //begin search for errors
   if(strlen($username) <= 1 or strlen($username) >=15){
      $dead = "true";
      $message .= "Username (2-14)<br>";
   }
   if(strlen($pass1) < 6 or strlen($pass1) > 20 or $pass1 !== $pass2) {
      $dead = "true";
      $message .= "Password (6-20) or passwords does not match";
   }
   if($dead = "false"){
      $username = strtolower(trim(strip_tags($username)));
      $pass1 = trim($pass1);
      $pass1 = md5($pass1);
      $query = mysql_query("SELECT * FROM members WHERE username ='$username'");
      $aantalrijen = mysql_num_rows($query);                   
      if($aantalrijen == 1){         
         print "<font face=verdana size=1>Sorry, your username exists allready.";         
      }
      else{
         $query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username','$pass1', '$ip','$status')";
         if(mysql_query($query1)){
             print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>";
         }   
      }
      
   }
   elseif($dead == "true"){
         print $message;
   }
}              
?>

 

MOD EDIT: code tags added.

The database has an error on this query:

$query = mysql_query("SELECT * FROM members WHERE username ='$username'");

 

Add in de-bugging:

$query = mysql_query("SELECT * FROM members WHERE username ='$username'") or trigger_error(mysql_error());

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.