Jump to content

[SOLVED] enum verification


overlordofevil

Recommended Posts

Hey all,

 

I am trying to set up a script that will look for a enum variable in my db and if it finds it sets the variable to the next one. problem I am running into is it stops at the first option.

 

function getwchar($uid)
{	
$query = "SELECT * FROM characters where id='$uid'";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result))
	{
	extract($row);
		if ($row[wchar] = 'quinary')
		{
		header("Location: charerror.php");
		}
		elseif ($row[wchar] = 'quaternary')
		{
		$wchar = 'quinary';	
		}
		elseif ($row[wchar] = 'tertiary')
		{
		$wchar = 'quaternary';	
		}
		elseif ($row[wchar] = 'secondary')
		{
		$wchar = 'tertiary';	
		}
		elseif ($row[wchar] = 'primary')
		{
		$wchar = 'secondary';	
		}
		else
		{
		$wchar = 'primary';
		}
	}
return $wchar;
}

 

I have moved the options around and it always stops at the first one. If someone could point me in the right direction I would appreciate it.

Link to comment
Share on other sites

I can't see what is wrong with the code though I did clean it up a little:

function getwchar($uid) {
    $query = "SELECT * FROM characters where id='$uid'";
    $result = mysql_query($query) or die (mysql_error());

    $wchar = NULL;
    while($row = mysql_fetch_assoc($result)) {
        if($row['wchar'] = 'quinary') {
            header("Location: charerror.php");
        } elseif($row['wchar'] = 'quaternary') {
            $wchar = 'quinary';
        } elseif($row['wchar'] = 'tertiary') {
            $wchar = 'quaternary';
        } elseif($row['wchar'] = 'secondary') {
            $wchar = 'tertiary';
        } elseif($row['wchar'] = 'primary') {
            $wchar = 'secondary';
        } else {
            $wchar = 'primary';
        }
    }

    return $wchar;
}

 

The only thing I can think of is that your query is only returning one row of data.

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.