MySQL Forums
Forum List  »  PHP

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Posted by: Jessica Randall
Date: October 13, 2009 06:29PM

I'm trying to make a login screen and I am getting this message and can't figure our why. Any help would be much appreciated.

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in ....

My code:

<?php
if(count($_POST) > 0) {
$username = $_POST['username'];
$passphrase = $_POST['passphrase'];

require("mysql.php");

$result = mysql_query("SELECT id FROM login WHERE username='$username' AND passphrase=MD5('$passphrase') ");
$row = mysql_fetch_assoc($result);
$id = $row['id'];

if($id > 0) {
session_start();
$_SESSION['logged_in'] = TRUE;

header('Location: index.php');
}else{
$status = "<p>Invalid username and/or password. Please try again.</p>";
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en-US" lang="en-US">
<head>
<title>GloveGameBoxing.com | Admin Login</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<link type="text/css" rel="stylesheet" media="screen" href="css/default.css" />
<script type="text/javascript">
<!--
window.onload = function() {
document.forms[0].elements[0].focus();
}
-->
</script>
</head>
<body>
<h1>GloveGameBoxing.com | Admin Login</h1>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<dl>
<dt><label for="login">Login</label></dt>
<dd><input type="text" name="login" id="login" /></dd>
<dt><label for="passphrase">Password</label></dt>
<dd><input type="password" name="passphrase" id="passphrase" /></dd>
</dl>
<div>
<input type="submit" name="submit" value="Log In" />
<input type="reset" name="reset" value="Reset" />
</div>
</form>
</body>
</html>

It's getting messed up with this: $row = mysql_fetch_assoc($result);

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.