OriginalSunny Posted April 19, 2006 Share Posted April 19, 2006 I have tried create a login page for an administrator so that if the value in admin is 1 it will let the user go through to the next page but it just doesnt work. The code i have used is:$sql1 = "SELECT admin FROM EmployeeWHERE empUsername='$_POST[empUsername]'"; $result1 = mysql_query($sql1)or die("Couldn't execute query."); if ($result1 == 1){....(go through to the next page)}else{(print error message)}No matter what i do it just seems to output the error message. I have stored the value 1 for one of the employees and 0 for the other but it still doesnt work. Is it an error in my code?? (I have also tried to put "" around the 1 highlighted in bold). Please help! Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 19, 2006 Share Posted April 19, 2006 have you tried using SELCT * instead of SELECT admin... ? Quote Link to comment Share on other sites More sharing options...
OriginalSunny Posted April 19, 2006 Author Share Posted April 19, 2006 Tried it but still got the same problem. Its either reading in the admin value wrong or i have done something wrong in the coding. I am pretty sure it isnt reading the admin value in wrong however, but i cnat see whats wrong with the coding either. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 19, 2006 Share Posted April 19, 2006 are you sure the field names have been spelled correctly etc Quote Link to comment Share on other sites More sharing options...
Roberto Posted April 19, 2006 Share Posted April 19, 2006 [!--quoteo(post=366391:date=Apr 19 2006, 01:38 PM:name=OriginalSunny)--][div class=\'quotetop\']QUOTE(OriginalSunny @ Apr 19 2006, 01:38 PM) [snapback]366391[/snapback][/div][div class=\'quotemain\'][!--quotec--]I have tried create a login page for an administrator so that if the value in admin is 1 it will let the user go through to the next page but it just doesnt work. The code i have used is:$sql1 = "SELECT admin FROM EmployeeWHERE empUsername='$_POST[empUsername]'"; $result1 = mysql_query($sql1)or die("Couldn't execute query."); if ($result1 == 1){....(go through to the next page)}else{(print error message)}No matter what i do it just seems to output the error message. I have stored the value 1 for one of the employees and 0 for the other but it still doesnt work. Is it an error in my code?? (I have also tried to put "" around the 1 highlighted in bold). Please help![/quote]try[code]$sql1 = "SELECT admin FROM EmployeeWHERE empUsername='".$_POST['empUsername']."'";[/code]that's single quote, double quote .$_POST['empUsername']. double quoute, single quote, double quote.Rob Quote Link to comment Share on other sites More sharing options...
OriginalSunny Posted April 19, 2006 Author Share Posted April 19, 2006 Tried it. Still have no luck. Quote Link to comment Share on other sites More sharing options...
High_-_Tek Posted April 19, 2006 Share Posted April 19, 2006 [code]$sql1 = "SELECT admin FROM EmployeeWHERE empUsername='$_POST[empUsername]'";$result1 = mysql_query($sql1)or die("Couldn't execute query.");$result=mysql_fetch_array($result1);if ($result['admin'] == 1)[/code]You didnt get the stuff Quote Link to comment Share on other sites More sharing options...
OriginalSunny Posted April 20, 2006 Author Share Posted April 20, 2006 It worked. Thanks. Quote Link to comment 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.