``this code keeps kicking out the error 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a2595218/public_html/login.php on line 49

 with the  out-put " The username you enterted was not found "  

 I should be seeing the error " You must active your acount to play. $form";" `

there for i thinks it must be skipping over the data base bit or something like that ?,

-------------------------------------------

<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
?>
<HTML>
<HEAD>
<TITLE></TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19170">
<STYLE type=text/css>
BODY {
    FONT-FAMILY: verdana, arial, sans-serif
}
</STYLE>
</HEAD>
<BODY>
<?php 
  $form = "<form action='./login.php' method='post'>
    <table>    
    <TR>
    <TD>Username:</TD>
   <TD><input type ='text' name='username'></TD>
    </TR>
      <TR>
    <TD>Password:</TD>
   <TD><input type='password' name='password'></TD>
    </TR>
       <TR>
    <TD></TD>
   <TD><input  type='submit' value='Login' name='loginbtn' ></TD>
    </TR>

    </table>
    </form>";


    if($_POST['loginbtn']){
      $username = $_POST['username']; 
      $password =$_POST['password']; 

      if ($username){
      if ($password){
      require("connect.php");

      $password = md5(md5("dF56cdc".$password."W6bs7cb"));


      $query = mysql_query("SELECT * FROM users WHERE username='$username'");
      $numrows = mysql_num_rows($query);
      if ($numrows == 1){
          $row = mysql_fetch_assoc($query);
          $dbid =$row['id'];
          $dbusername = $row['username'];
          $dbpass = $row['password'];
          $dbactive = $row['active'];

          if($password = $dbpass) {
              if ($dbactive ==1){
                  $_SESSION['userid'] =$dbid;
                  $_SESSION['username'] =$dbusername;

                  echo " You have been logged in as <b>$dbuser</b><a herf='./member.php'>click here</a>to go somewhere";

                  }
                  else
                  echo " You must active your acount to play. $form";
          }


          else 
          echo " You did not enter right password. $form";
      }
      else
      echo "The username you enterted was not found . $form";

      mysql_close();

      }
      Else
        echo "You must enter password. $form"; 
      }
      Else
      Echo " You must enter User Name. $form";
    }
      else
      echo "$form";


 ?>
</BODY>
</HTML>

Any help ?

Thanks .

I assume that your connect.php includes a call to mysql_connect ... are you also checking to make sure the connection is successful?

Should your password hash be before tring to connect to the DB?

I assume that your connect.php includes a call to mysql_connect ... are you also checking to make sure the connection is successful?

Should your password hash be before tring to connect to the DB?t

yep the connect.php is conecting to the base, I have been copying a tutoural with this and still get the line 49 error.

manually run your query in mysql and then see what result it displays, and share it

what is happening is that the query result is returning as empty.

change the following

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

to

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

this will tell you whether the function mysql_query executed successfully or not.

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

=

Parse error: syntax error, unexpected T_VARIABLE in /home/a2595218/public_html/login.php on line 41

duz that mean it found something it was not spose to or not found something it was expecting to find ?

It means it found something incorrect in the php on that line. This error can also be caused by things like forgetting a semicolon, closing quote or bracket on an earlier line.

---

Hmm.. the code you have posted works fine for me. I am led to assume, then, that the error may be originating in your connect.php or is possibly data related (invalid characters, or disparity in the character set being used in php to that in mysql).

Hey ... just had another thought. Can you open the code file in a text editor and show whitespace characters? It is possible that there is an invalid invisible character somewhere that is causing a parse error for php - I have seen this happen before.

Just an idea.

it was or is a bug with my editor , every time I switch from code view to design view it messes up the code. Am looking for a new editor as we speek. :) thanks,

What editor are/were you using? (if you don't mind me asking)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.