problems with login script



Hi, I can't get this script to work.
I've used this exact script on other places and it works, but now i
get this error.

<code> Warning: mysql_fetch_array(): supplied argument is not a valid
MySQL result resource in C:\xampp\htdocs\uploads\login_script.php on
line 15 </code>

I can't see what is wrong.
Here is the script.

<code>
<?php
session_start();
$anvnamn = $_POST['usr'];
$losenord = $_POST['pwd'];

include "dbconnect.php";

$anv2 = mysql_real_escape_string($anvnamn, $dbconnect);
$los2 = mysql_real_escape_string($losenord, $dbconnect);

$sqlfraga = "SELECT anvnamn FROM administrator WHERE anvnamn = '" .
$anvnamn . "' AND losen = '" . $losenord . "'";
$res = mysql_query($sqlfraga, $dbconnect);

if($rad = mysql_fetch_array($res))
{
$_SESSION['logged_in_admin'] = true;
}
else
{
$_SESSION['logged_in_admin'] = false;
}
?>
<html>
<body>
<?php
if($_SESSION['logged_in_admin'])
{
echo("You are logged in");
include('index.php');

}
else
{
echo ("go away");
}
?>
</body>
</html>
</code>
.



Relevant Pages

  • Re: [PHP] syntax error
    ... Moving the *.php to a php5 and mysql 5.x site I get these errors: ... result resource in ... ... Probably the mysql extension is not found or not loaded (due to not being compiled with the right path or the default path in PHP is not the right one). ...
    (php.general)
  • Re: problems with login script
    ... I've used this exact script on other places and it works, ... anyways the problem was that i named the table administrators in the ...
    (comp.lang.php)
  • Re: local v remote
    ... PHP version problem? ... probably connecting to a locally-hosted mysql installation. ... Are you using the same connection string when you upload? ... You should also always try to pass the resource to the mysql_query function ...
    (php.general)
  • Re: Help Me
    ... EXCELLENT resource for MANY subjects. ... php is not much different. ... database (as opposed to mysql). ...
    (comp.lang.php)
  • Re: problems with login script
    ... I've used this exact script on other places and it works, ... this error message means that you can't fetch rows from $res because the database query failed. ...
    (comp.lang.php)