RON_ron Posted November 18, 2010 Share Posted November 18, 2010 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/ Share on other sites More sharing options...
ManiacDan Posted November 18, 2010 Share Posted November 18, 2010 Sure it does! Hint: "Doesn't work" has no meaning. Explain. Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136260 Share on other sites More sharing options...
RON_ron Posted November 18, 2010 Author Share Posted November 18, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136263 Share on other sites More sharing options...
ManiacDan Posted November 18, 2010 Share Posted November 18, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136268 Share on other sites More sharing options...
RON_ron Posted November 18, 2010 Author Share Posted November 18, 2010 The error I'm getting is unexpected $end in /home/xxx/public_html/xxx/test.php on line 22 line 22 is ?> Any idea why? Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136272 Share on other sites More sharing options...
shlumph Posted November 18, 2010 Share Posted November 18, 2010 Your bracketing is messed up, look: if(mysql_num_rows($result1)) { } else { if(mysql_num_rows ($result) == 0) { } else { } Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136277 Share on other sites More sharing options...
litebearer Posted November 18, 2010 Share Posted November 18, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136279 Share on other sites More sharing options...
ManiacDan Posted November 18, 2010 Share Posted November 18, 2010 Three. Three responses before you gave the actual error you've had all along. Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136285 Share on other sites More sharing options...
RON_ron Posted November 18, 2010 Author Share Posted November 18, 2010 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); // Quote Link to comment https://forums.phpfreaks.com/topic/219112-coding-help/#findComment-1136287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.