I am trying to run a beginner mysql program which checks two arguments against stored values in the database. I have one database named 'sl493' on the server, which has a table 'metauser' and 1 row of data. When i try to run the program, i only get "Connected successfully" and no 'login ok'
<html>
<head>
<title>Connecting MySQL Server</title>
</head>
<body>
<?php
$username = 'fahad';
$password = '2';
$dbhost = '*********.edu';
$dbuser = '*******';
$dbpass = '*******';
$conn = mysql_connect($dbhost, $dbuser, $dbpass); // connect to server
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db('sl493',$conn); //pick sl493 database
$result = mysql_query("SELECT *
FROM metauser
WHERE metauser.username = $username;
AND metauser.password = $password") ; //select data from metauser table
$row = mysql_fetch_assoc($result);
if($row['username'] == $username)
{
echo 'Login ok';
}
else
{
'Login failed';
}
?>
</body>
</html>
Here's a snapshot of the database: https://i.stack.imgur.com/0PUPG.jpg
Any suggestions about what's going wrong ?