Hi guys how are you doing,
I am unable to execute very basic php script connecting with mysql. being a noob I just need a quick fix thats all..
here is the code:
<?php session_start(); ?>
<html>
<body>
<form action='index.php?login=yes' method=POST>
Username: <input type=text name='user'><br/>
Password: <input type=password name='pass'><br/>
<input type=submit value='SignIn!'>
</form>
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
$login=$_GET['login'];
if($login=='yes'){
$con=mysql_connect('localhost','root','');
mysql_select_db('test');
$get=mysql_query("SELECT count(id) FROM database WHERE user='$user' and pass='$pass'");
$result=mysql_result($get,0);
mysql_close($con);
if($result!=1) echo "Login failure";
else{
echo "Login success !";
$_SESSION['user']=$user;
};
};
?>
<body>
</html>
error I am getting is:
Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\roooooot\xampp\htdocs\index.php on line 22
Login failure
1. I am assuming root and '' pass is to login mysql.
2. test is the database
3. 'database' is the table where it is checking user/pass
the rest is straightforward.
can anyone explain what could be wrong. getting same error with a nonexisting database.
Thank you!