Dada78 wrote:Yes still getting the error....
The same error or another error?
Dada78 wrote:Yes still getting the error....
The same error or another error?
Piranha wrote:The same error or another error?
Have I mentioned a different error? For the second time, yes I am still getting the same error.... :rolleyes:
überfuzz wrote:I don't know that much about sql syntax, might be only form int():
$sql="SELECT * FROM $tbl_name WHERE username=$email and password=$password";
????
That is the same code I was using that I listed in my first post.
Dada78 wrote:Ok I am getting this error "mysql_num_rows(): supplied argument is not a valid MySQL result resource" from the line of code below
// Mysql_num_row is counting table row $count=mysql_num_rows($result);
So I replace it when this bit of code:
$result = MYSQL_QUERY($sql) or die('Query failed: ' . mysql_error() . "<br />\n$sql");
This is what it returned:
Any idea what this means and how to fix it?
Here is the full code
<?php include ('db_connect.php'); // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$database")or die("cannot select DB"); // email and password sent from signup form $email=$_POST['email']; $password=$_POST['password']; $sql="SELECT * FROM $tbl_name WHERE username='$email' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $email and $password, table row must be 1 row if($count==1){ // Register $email, $password and redirect to file "user.php" session_register("email"); session_register("password"); header("location:user.php"); }else { $error = 'Wrong Email or Password'; } ?>
Not sure why you edited this post. the username and passwords were fake for testing purposes and were to test log on to a link I never posted to a log on page that doesn't exist.....
Anyways, I am still getting this same error. So if anyone can see why and could help me out that would be great...
-Thanks
$sql="SELECT * FROM $tbl_name WHERE username='$email' and password='$password'";
Brad already told you the problem. In that line of code, you use $tbl_name - however we can't see you assigning this variable anywhere.
Change $tbl_name to the name of the table in the database.
If you've already changed $tbl_name, show us a fresh copy of the part of code that queries the DB, as well as the output from the or die() statement as you did before.
dougal85 wrote:
$sql="SELECT * FROM $tbl_name WHERE username='$email' and password='$password'";
Brad already told you the problem. In that line of code, you use $tbl_name - however we can't see you assigning this variable anywhere.
Change $tbl_name to the name of the table in the database.
Read post 3 please and you would see I already did that...
-Thanks
ok, do you still get the exact same error? check the field names are the same as in the database.
I got it fixed after some sleep I had this
username='$email
which should have been this
email='$email'
That is why you should always copy and paste when asking for help. Typing it may cause two problems, new errors that are not in the code and it may cause you to solve errors that were there before.
hai
i am stuck in this error
mysql_num_rows(): supplied argument is not a valid MySQL result resource :>on line 28
pls help......this is the code
<?php
session_start();
session_destroy();
$message="";
$Login=$POST['Login'];
if($Login){
$username=$POST['username'];
$md5_password=md5($_POST['password']);
$host="localhost";
$db_user="root";
$db_password="";
$database="tutorial";
$db=mysql_connect($host,$db_user);
mysql_select_db($database,$db);
// Check matching of username and password.
$srch="select * from admin where username='$username' and password='$md5_password'";
$result=mysql_query($srch,$db);
$num_rows = mysql_num_rows($result);
if($num_rows!='0') { // If match.
session_register("username"); // Craete session username.
header("location:main.php"); // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}
} // End Login authorize check.
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php echo $message; ?>
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
<table>
<tr>
<td>User : </td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
<input name="Login" type="submit" id="Login" value="Login" />
</form>
</body>
</html>
ashercharles, you should start a new thread with your question. Otherwise people won't see it or just don't answer.