Hi everyone
I am running the following code, the field names in the table are correct. i recived the following error:
Warning: odbc_fetch_row(): 3 is not a valid ODBC result resource in C:\web\root\memlogin1.php on line 42
can anyone see why the error is occuring?
<?PHP
$conn=odbc_connect('DHST','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
if (!isset($_POST['submit'])) //if they haven't pressed the submit button, then show the form
{
require ($_SERVER['DOCUMENT_ROOT']. '/includes/header.php');
?>
<tr>
<td width="780" colspan="4" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<h2>My Login Form</h2>
<form action="memlogin1.php" method="post">
Username: <input type="text" name="username" ><br>
Password: <input type="password" name="password" ><br>
<input type="submit" name="submit" value="Login" ><br>
</form>
</td>
</tr>
<?php
require ($_SERVER['DOCUMENT_ROOT']. '/includes/footer.php');
}
else //they pressed the button so process their input
{
$query = "SELECT * FROM member";
// $result = mysql_query($query);
$rs=odbc_exec($conn,$query);
while (odbc_fetch_row($rs))
{
if($_POST['username'] == odbc_result($rs,"user") && $_POST['password'] == odbc_result($rs,"pass")) //if they got it right, let's go on
{
session_start();
session_register("memsession"); //set a variable for use later
$id = session_id(); //let's grab the session ID for those who don't have cookies
$url = "Location: products.php?sid=" . $id;
header($url);
exit();
}
else //they didnt log in correctly back to login
{
require ($_SERVER['DOCUMENT_ROOT']. '/includes/header.php');
?>
<tr>
<td width="780" colspan="4" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<h2>My Login Form</h2>
<p>Password/Username Is Invalid<p>
<form action="memlogin1.php" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password" ><br>
<input type="submit" name="submit" value="Login" ><br>
</form>
</td>
</tr>
<?PHP
require ($_SERVER['DOCUMENT_ROOT']. '/includes/footer.php');
}
odbc_close($conn);
}
}
?>