Forum Moderators: coopster

Message Too Old, No Replies

Spot the error! ODBC recordset

         

nshack31

3:05 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



ok my code is as follows

<?php
$conn=odbc_connect('league','','');
$me=$_REQUEST['username'];
$pass=$_REQUEST['password'];

if (!$conn)
{
exit(
"Connection Failed: " . $conn);
}
$sql="SELECT * FROM users WHERE username = '$me' AND password = '$pass'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
else if (!rs.next == true)
{
echo "login success";
}
else
{
echo "login failure";
}
odbc_close($conn);
?>

this line is not working "else if (!rs.next == true)" that works for JSP but not PHP, what is the command for PHP!?!

nshack31

3:45 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



ive also tried the following code......

<html><body><?php
$conn=odbc_connect('league','','');
$me=$_REQUEST['username'];
$pass=$_REQUEST['password'];

if (!$conn)
{
exit(
"Connection Failed: " . $conn);
}
$sql="SELECT * FROM users WHERE username = '$me' AND password = '$pass'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
while (odbc_fetch_row($rs))
{
$username=odbc_result($rs,"username");
$password=odbc_result($rs,"password");
if ($username = $me AND $password = $pass)
{
print('yes');
}
else
{
print('error');
}
}
odbc_close($conn);
;?>
</body></html>

This works apart from the ..
else
{
print('error');
}

part, any ideas?!