2013-02-27 93 views
0

下面是我的代码PHP如果... ...其他语句返回错误

 <?php 
//Vars 
$alreadylogged = 0; 
$username = 0; 
//End Var 
//Start Script 
print 'Welcome to CraftedList!</br>' 
if ($alreadylogged=="1") *Side note, this line is line 34* 
{ 
    print 'You are currently logged in as'. $username .'!'; 
} 
else 
{ 
    print 'You are not logged in!' 
} 
    ?> 

但是,当我执行它本地主机XAMPP客户端上,它返回此错误。

Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\phptest\index.php on line 34

我检查了W3学校,我的代码与他们的类似。

+3

速度越快停止使用W3Schools的的更好,你会没事的。 – GordonsBeard 2013-02-27 01:30:52

回答

6

你缺少一个;

print 'Welcome to CraftedList!</br>'; 
            ^here 
+1

谢谢,我不能相信我错过了一个简单的错误... – OPatel 2013-02-27 01:30:15

+2

@ user1185220在'print'上也缺少一个分号您没有登录!'行。 – Pang 2013-02-27 01:31:22

+0

@Pang对,我甚至没有读到那么远...... – jeroen 2013-02-27 01:32:20

2

失踪;

这里:

print 'Welcome to CraftedList!</br>' 

这里:

print 'You are not logged in!'