dongtaotao19830418 2013-01-25 18:49
浏览 40

如何从phpmyadmin引用值以将用户与客户分开?

I am trying to create a user login page. Upon successful registration admins are assigned a value of "A" in my database and customers a "C". Upon successful login customers will be directed to one page and admins to another. I created three session variables, their userId, userFName and their userType. I want to create an if statement to check the value of userType and have tried everything but I still get the error message "Parse error: syntax error, unexpected T_ELSE...on line 74".

`//create a session variable for this customer who has just logged in
//store his id and first name and usertype in this session variable     
$_SESSION['c_userid']=$userArray['userId'];
$_SESSION['c_fname']=$userArray['userFName'];
$_SESSION['c_usertype']=$userArray['userType'];

//if seperating customers from administrators
if ($userArray['userType']) 'C';
{
echo "<p>You are successfully logged in as a customer";
}
else;
{
echo "<p>You are successfully logged in as an administrator";
}`

I have also edited the if statement to include and "=" sign after the var but it returns the error message "Parse error: syntax error, unexpected '='....on line 70"

All and any help is much appreciated.

P.S newbie on a learning curve here so patience is appreciated. Been scratching my head all week over this but not making any progress. I have researched php.net etc so this question is a last resort.

  • 写回答

1条回答 默认 最新

  • dsfjnxjlbqv9812 2013-01-25 18:50
    关注

    This syntax is all wrong:

    if ($userArray['userType']) 'C';
    

    should be

    if ($userArray['userType'] === 'C')
    
    • Everything goes in the parenthesis
    • no semi-colon after the parenthesis

      else;

    should be:

    else // no semi-colon
    
    评论

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示