Jump to content

login check


morrisjohnny

Recommended Posts

i'm sur ei've had this code working on windows yet when i switched to linux it doesn't work anyone see what the problem is?I get an error saying"mysql_num_rows supplied argument is not a valid mysql result resource (directory) on line 22"and"mysql_num_rows supplied argument is not a valid mysql result resource (directory) on line 32"line 22 is"if(mysql_num_rows($query) == 1)"and line 32 is"mysql_close($db);"here is the code for the login_check

<?phpsession_start();$logged_in = false;$msg = "";if ($_SESSION['online'])  $logged_in = true;else if (isset($_POST['username'])){  $db=mysql_connect("localhost", "root", "");  mysql_select_db("mt", $db);  $username = htmlentities($_POST['username']);  $password = htmlentities($_POST['password']);  $username = mysql_real_escape_string($username);  $password = mysql_real_escape_string($password);  $query = mysql_query("SELECT login, pazzword FROM Users WHERE login = '$username' AND pazzword = '$password'");  if(mysql_num_rows($query) == 1) /*line 23*/  {    $_SESSION['online'] = true;    $_SESSION['username'] = $username;    $logged_in = true;  }  else    $msg .= "The username and password did not match.<br /><br />";  mysql_free_result($query);   mysql_close($db); /*Line 32*/}?>

Link to comment
Share on other sites

The row that causes the problem is this one:

$query = mysql_query("SELECT login, pazzword FROM Users WHERE login = '$username' AND pazzword = '$password'");

Two suggestions:Add

echo mysql_error();

after the mysql_query-lineMake sure that you have the table Users set up right...

Link to comment
Share on other sites

But the case-sensitivity wouldn't lie with the OS in this case as he uses MySQL on both systems it would behave in the same way (basically) (or isn't it like that? never used MySQL on win)

Link to comment
Share on other sites

I read somewhere that windows is not case sensitive at all, though I use Linux myself
Yeah, with SQL Server and MySQL on Windows, the following queries are identical:
SELECT userid, username FROM users;

SELECT UserID, UserName FROM Users;

SELECT UsErId, UsErNaMe FROM uSeRs;

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...