Jump to content

COding help


RON_ron

Recommended Posts

this doesn't work. Please help fix this.

 

 

$result1=mysql_query("SELECT * FROM applicants WHERE username = '$user' AND status = 'PendingXCD'");

if(mysql_num_rows($result1)) {

$login = "&err=In progress.";

echo($login);

}

else {

$result=mysql_query("SELECT * FROM  comp WHERE username = '$user' AND password ='$pass'");

if(mysql_num_rows ($result) == 0) {

$login = "&err=Please retry.";

echo($login);

} else {

$row = mysql_fetch_array($result);

$user=$row['user'];

$pass=$row['pass'];

$login = "$user=" . $user . "$pass=" . $pass . "&err=Successful.";

echo($login);

}

?>

Link to comment
Share on other sites

Hey Dan...

 

I'm trying to match a user name in database "applicants" and if it exist and hold the value "PendingXCD" then it returns echo "A"

if not

it should search for the same username in batabase "comp" and if it exist it should match againts it's the password and echo "B"

if not

echo "C"

 

But I'm unable to do it. Please help.

Link to comment
Share on other sites

That's basically what this code does.  Have you tried any sort of debugging on your own?

 

Echo the values of all the variables you're using, make sure they're correct.

 

Echo the queries, make sure they're not malformed.

 

Run the queries by hand, see if the output is what you expect.

 

Etc etc.

Link to comment
Share on other sites

Just a cursory glance...

// Is PendingXCD a constant OR did you forget the Dollar Sign?<br>
$result1=mysql_query("SELECT * FROM applicants WHERE username = '$user' AND status = 'PendingXCD'");
if(mysql_num_rows($result1)) {
$login = "&err=In progress.";
echo($login);
}else {
$result=mysql_query("SELECT * FROM comp WHERE username = '$user' AND password ='$pass'");
if(mysql_num_rows ($result) == 0) {
	$login = "&err=Please retry.";
	echo($login);
} else {
	$row = mysql_fetch_array($result);
	$user=$row['user'];
	$pass=$row['pass'];
	$login = "$user=" . $user . "$pass=" . $pass . "&err=Successful.";
	echo($login);
}
} // THIS BRACE IS MISSING

Link to comment
Share on other sites

Wel spotted litebearer and shlumph.

 

// Is PendingXCD a constant OR did you forget the Dollar Sign?<br>

nope. "PendingXCD" the word I want to match againts the name.

 

But still that doesn't work for the first condition.

 

$result1=mysql_query("SELECT * FROM applicants WHERE username = '$user' AND status = 'PendingXCD'");
if(mysql_num_rows($result1)) {
$login = "&err=In progress.";
echo($login);
//

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.