2017-07-03 94 views
1

我試圖做,如果有人(1)被檢查出他的名字是真實驗證的代碼,但它並沒有真正if語句(驗證)

<?php if($usrn['verified'] == 1): { ?> 

<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i> 


<?php } endif; ?> 

<?php 
$usern = protect($_GET['usern']); 
$sql = mysql_query("SELECT * FROM purchasify_users WHERE usern='$usern' OR id='$id'"); 
if(mysql_num_rows($sql)==0) { $redirect = $web['url']."not_found"; header("Location: $redirect"); } 
$row = mysql_fetch_array($sql); 
?> 
+2

你的語法顯然是不正確的 –

+0

什麼是正確的語法? –

+0

嗨,歡迎來到Stack Overflow,請閱讀如何創建[Minimal,Complete和Verifiable示例](https://stackoverflow.com/help/mcve),並查看[如何提出好問題](https:/ /stackoverflow.com/help/how-to-ask),這樣你可以增加獲得反饋和有用答案的機會。 – DarkCygnus

回答

0

更新你這樣的代碼

//假設$ usrn ['verified'] == 1;

<?php 
$usrn['verified'] =1; 
if($usrn['verified'] == 1) { ?> 

<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i> 


<?php } ?> 
+0

它不會工作; c –

+0

<?php $ usern = protect($ _ GET ['usern']); $ sql = mysql_query(「SELECT * FROM purchasify_users WHERE usern ='$ usern'or id ='$ id'」); if(mysql_num_rows($ sql)== 0){$ redirect = $ web ['url']。「not_found」;標題(「位置:$重定向」); } $ row = mysql_fetch_array($ sql); ?> –

+0

它會工作,如果你的價值是好的 –

0
<?php if($usrn['verified'] == 1) { ?> 

    <i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i> 

<?php } ?> 

試試這個。

+0

我使用正確的PHP(更新) –

0

您在這裏混合了兩種不同的條件。

您可以使用:

if (condition) { 
    // do stuff 
} 

if (condition): 
    // do stuff 
endif; 

錯誤

你正在做的:

if (condition): { 
    // do stuff 
} 

這會引發語法錯誤。

進一步信息

Official PHP Documentation: Conditionals

0

嘗試這個快捷

$usrn['verified']=1; 
 
echo ($usrn['verified'] == 1)? '<i class="fa fa-check-circle verified verified-sm showTooltip" title="Verified User" data-toggle="tooltip" data-placement="right"></i>' : '';

回波($ usrn [ '已驗證'] == 1)? 'ghbftjfgj':'';