By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,420 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

mysql_query / password error

P: 7
Apache 2.0
PHP 4.4
MySQL 5.0
=========
Ok, here what is going on! Every time when I trying to login into system I’m getting message (its last “else” in F_LogIn function):
“Nothing is working”
and so result of this:
“You could not be logged in”
I don’t know why it’s happen, but by testing my query, I found out that problem in “user_password”, without this parameter everything is working smoothly. To be more precise, the query is not returning any row from DB.
Because of this I’m seriously stuck and can’t move on with this project. I didn’t found any tips in internet so decided to post here.

[php]<?php
$user_name = $_POST ["user_name"];
$user_password = $_POST ["user_password"];
session_start ();
if ($user_name && $user_password)
{
if (F_LogIn ($user_name, $user_password))
{
$valid_user = $user_name;
$_SESSION ['valid_user'] = $user_name;
}
else
{
print "You could not be logged in <br />";
print "NAME = $user_name <br /> PASSWORD = $user_password <br />";
exit;
}
}
F_CheckValidUser ();
?>

<br />
<a href = "LogOut.php">LogOut</a>

<?php
function F_LogIn ($user_name, $user_password)
{
$connection_status = F_DBConnect();
if (!$connection_status)
{
print "No connection to DB";
return false;
}
$query = "SELECT * FROM tbl_user_detail WHERE clm_user_name = '$user_name' AND clm_password = OLD_PASSWORD ('$user_password')";
$query_result = mysql_query ($query, $connection_status);
//$query_result_2 = mysql_fetch_row ($query_result);
//print $query_result_2 ["clm_user_name"];
if (!$query_result)
{
print "Invalide query";
return false;
}
else
{
if (mysql_num_rows ($query_result))
{
print "Query OK" . mysql_num_rows ($query_result) . "<br />";
return true;
}
else
{
print "<br />Nothing is working " . mysql_num_rows ($query_result) . "<br />";
return false;
}
}
}

function F_DBConnect ()
{
$connection_status = mysql_pconnect ("localhost", "root", "111");
if (!$connection_status)
{
return false;
}
if (!mysql_select_db ("test", $connection_status))
{
return false;
}
return $connection_status;
}

function F_CheckValidUser ()
{
//global $valid_user;
if (isset($_SESSION ['valid_user']))
{
print "Logged in as " . $valid_user . "<br />";
?>

<br />
<a href = "LogOutTest.php"> Log Out Test</a>
<br />

<?php
}
else
{
print "You are not logged in <br />";
?>

<a href = "LogInForm.php">Log In</a>
<br />
<a href = "LogOut.php">Log Out</a>
<br />
<a href = "LogOutTest.php"> Log Out Test</a>

<?php
exit;
}
}
?>[/php]
And one more thing, the query that used to register user is:
[php]...
$query_result = mysql_query ("INSERT INTO tbl_user_detail
VALUES ('$user_name', OLD_PASSWORD('$user_password'), '$user_email')");...[/php]
Mar 1 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.