2017-03-15 45 views
-2

我環顧四周無法找到答案,幫助我,看不到任何明顯的問題。我已經收到此錯誤:解析錯誤:語法錯誤,意外'回聲'(T_ECHO)在C: ...在線12

Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:... on line 12

<?php 

include 'dbh.php'; 

$uid = $_POST['uid']; 
$pwd = $_POST['pwd']; 

$sql = "SELECT * FROM user WHERE uid='$uid' AND pwd='$pwd'"; 
$result = mysqli_query($conn, $sql); 

if (!$row = mysqli_fetch_assoc($result) { 
    echo "Your username or password is incorrect!"; 
} else { 
    echo "You are logged in!"; 
} 

任何幫助表示讚賞!

+0

缺少')'... – AbraCadaver

+1

也是開放的SQL注入,應該散列密碼。 – chris85

回答

0

你缺少你if()聲明的括號:

<?php 

include 'dbh.php'; 

$uid = $_POST['uid']; 
$pwd = $_POST['pwd']; 

$sql = "SELECT * FROM user WHERE uid='$uid' AND pwd='$pwd'"; 
$result = mysqli_query($conn, $sql); 

if (!$row = mysqli_fetch_assoc($result)) { 
    echo "Your username or password is incorrect!"; 
} else { 
    echo "You are logged in!"; 
} 
相關問題