Jump to content

Recommended Posts

I have a db to script issue when I try to check a users level.

 

Here is the SQL for the field I am checking.

fld_user_level enum('0','1','2','3','4','5') NOT NULL default '1',

 

Here is the php code that is failing on me.  It is supposed to to retrieve a users level than if it is a level 2 and higher user it is supposed to do a certain operation.  If a level 1 user it does a different operation.  Except it runs the script as if all users are level 1.  I am fairly sure the issue is because in the DB user_level is enum but if I switch it to int the db errors when I try to do this.  Any suggestions on what to do would be appreciated!

$sql_validation_check = mysql_query("SELECT fld_user_level='$user_level' FROM tbl_user_access WHERE fld_emailaddress='$email_address'");

if($user_level > 1) {
          
          Stuff happens here for lvl 2 and higher users;

} else {

          Stuff happens here for lvl 1 users;
}

dont know what do you mean by this!

 

SELECT fld_user_level='$user_level' FROM tbl_user_access WHERE fld_emailaddress='$email_address'

 

I am trying to retrieve the user_level From tbl_user_access Where is based on the users email.

Its pretty simple and straight forward.

maybe you mean..

$sql_validation_check = mysql_query("SELECT * FROM tbl_user_access WHERE fld_emailaddress='$email_address'");
$row =mysql_fetch_array($sql_validation_check);

if($row['fld_user_level'] > 1) {
          
          Stuff happens here for lvl 2 and higher users;

} else {

          Stuff happens here for lvl 1 users;
}

Nope I still have the same problem!  This is what I updated it too.

 

$sql_validation_check = mysql_query("SELECT fld_user_level='$user_level' FROM tbl_user_access WHERE fld_emailaddress='$email_address'");

$user_level = mysql_query($sql_validation_check);

if($user_level > 1) {
          
          Stuff happens here for lvl 2 and higher users;

} else {

          Stuff happens here for lvl 1 users;
}

Please use this code[teng84]:

$sql_validation_check = mysql_query("SELECT * FROM tbl_user_access WHERE fld_emailaddress='$email_address'");
$row =mysql_fetch_array($sql_validation_check);

if($row['fld_user_level'] > 1) {
          
          Stuff happens here for lvl 2 and higher users;

} else {

          Stuff happens here for lvl 1 users;
}

 

Your code is completely wrong.

Please use this code[teng84]:

$sql_validation_check = mysql_query("SELECT * FROM tbl_user_access WHERE fld_emailaddress='$email_address'");
$row =mysql_fetch_array($sql_validation_check);

if($row['fld_user_level'] > 1) {
          
          Stuff happens here for lvl 2 and higher users;

} else {

          Stuff happens here for lvl 1 users;
}

 

Your code is completely wrong.

 

 

This code will select all users won't it?  I just want 1 particular user!

When using the SELECT statement it should be like this

 

SELECT `field_name` FROM `table_name` WHERE `field_name_data` = '" . $variable . "'

 

 

You CANNOT use a variable when trying to select a field.

 

Yea I will give that a try!

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.