-6

Parse error: syntax error, unexpected T_IF, expecting ')'

What should I do? .please anyone help me out

         $option = $_GET['I-would-like'];
         $userdata = array(
            'user_login' => $username,
            'user_pass' => $password,
            'user_email' => $email,
            'nickname' => reset($name_parts),
            'display_name' => $name,
            'first_name' => reset($name_parts),
            'last_name' => end($name_parts),    
            if ($option == 'A quotation' OR  $option == 'Information')// Error occurs here
        {
            'role' => 'customer'
            } else if($option == 'To become a Partner') 
            {
            'role' => 'partners'
            } else if ($option == 'Training / Coaching')
                {
            'role' => 'students'
            }
        );
devpro
  • 16,184
  • 3
  • 27
  • 38
pradeep
  • 5
  • 6

2 Answers2

1
Update with below code,

 $option = $_GET['I-would-like'];

    if ($option == 'A quotation' OR  $option == 'Information')
    {
        $role='customer';
    } else if($option == 'To become a Partner') 
    {
        $role='partners';
    } else if ($option == 'Training / Coaching')
    {
        $role='students';
    }


    $userdata = array(
        'user_login' => $username,
        'user_pass' => $password,
        'user_email' => $email,
        'nickname' => reset($name_parts),
        'display_name' => $name,
        'first_name' => reset($name_parts),
        'last_name' => end($name_parts),    
        'role' =>  $role
    );
user3040610
  • 750
  • 4
  • 15
0

try this, get role value outside array

$role = "";
$option = $_GET['I-would-like'];
$option = trim($option);
if ($option == 'A quotation' || $option == 'Information')
{
    $role = 'customer';
} else if($option == 'To become a Partner') 
{
    $role = 'partners';
} else if ($option == 'Training / Coaching')
{
    $role =  'students';
}


$userdata = array(
    'user_login' => $username,
    'user_pass' => $password,
    'user_email' => $email,
    'nickname' => reset($name_parts),
    'display_name' => $name,
    'first_name' => reset($name_parts),
    'last_name' => end($name_parts),    
    'role' => $role
);
Dave
  • 3,073
  • 7
  • 20
  • 33
  • but if I have selected the option as " A quotation" I mighty get the value customer right? but Im getting the value as none. I dont knw – pradeep Sep 21 '16 at 10:53
  • @pradeep : use trim in $option and I edited my answer . – Dave Sep 21 '16 at 11:01
  • error remains the same .......... anyother solution ?Mr.dave – pradeep Sep 21 '16 at 11:26
  • instead of get ($option = $_GET['I-would-like'];)method I have changed into post($option = $_POST["I-would-like"];)... now its working fine... Thanx to all.. – pradeep Sep 22 '16 at 04:53
  • in this type of case, i recommendation you use $_REQUEST. – Dave Sep 22 '16 at 04:56