I’m trying to write a simple login script but I’m getting the resource id #3 error.
code is
Code:
<?php
$host="localhost";
$user="root";
$password="";
$db="admin";
$tableadmin="admin1";
$adminuser= $_POST["adminuser"];
$adminpass= $_POST["adminpass"];
$link = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($db,$link)
or die ("Couldn't select database");
$result = "SELECT * FROM admin1 WHERE adminuser='$adminuser' AND adminpass='$adminpass'";
$query = mysql_query($result)
or die ("Couldn't execute query.");
echo "<br><br>$query<br><br>";
//heres the problem
if (mysql_num_rows($result) > 0)
{
$_SESSION["authenticatedUser"]= $adminuser;
header("Location: loggedon.php");
}
else
{
$_SESSION["message"]="could not connect to database as $adminuser";
header("Location: loginform.php");
}
?>
Hope someone can help
why wouldnt the SQL statement be called $query and
the mysql_query be stored as the result?
try this
Code:
$query = "SELECT COUNT(*) as cnt FROM admin1 WHERE adminuser='$adminuser' AND adminpass='$adminpass'";
$result = mysql_query($query) or die ("Couldn't execute query.");
$row = mysql_fetch_array($result);
if ($row['cnt'] > 0)
{
$_SESSION["authenticatedUser"]= $adminuser;
header("Location: loggedon.php");
}
thanks for your help but Still not working
putt @ before mysql_query like this
Code:
$result = @mysql_query($query) or die ("Couldn't execute query.");
still have a problem
I think u Check your HTML for blank lines
