2014-11-22 97 views
0

你好我有用於搜索頁面,但我提示以下錯誤:獲得非對象錯誤的性質

試圖讓非對象的財產..........

有同樣的問題,但我還沒有找到我的問題的答案。

下面是代碼:

<html> 
<head> 
</head> 
<body> 
<form action="" name="myform" method="post"> 
<table width="1330" border="0" align="center"> 
<tr><td colspan="45" align="left"><a href="../Admin Panel.php"><img src="../Images for admin panel/backbutton.jpg" /></a></td></tr> 
    <th height="47" colspan="11"><font size="+3">Remote Employee Search Page</font></th></tr> 
</tr> 
</tr> 
<th colspan="11"><input type="text" name="search" size="33">&nbsp;<input type="submit" id="Submitbutton" value="Search" style=" font: 15px verdana; 
    text-decoration: none; 
    background-color: #EEEEEE; 
    color: #333333; 
    padding: 2px 6px 2px 6px; 
    border-top: 1px solid #CCCCCC; 
    border-right: 1px solid #333333; 
    border-bottom: 1px solid #333333; 
    border-left: 1px solid #CCCCCC; 
    cursor:pointer;"><br ></th></tr> 


<?php 

require_once('../db.php'); 
@$search = $_POST['Search']; 


$query = "SELECT 

RemoteEmployeeID, 
RemoteEmployeeFullName, 
    RemoteEmployeeNIC, 
    RemoteEmployeePassword, 
    RemoteEmployeePhone, 
    RemoteEmployeeEmail, 
     PDName, DistrictName, 
     ProvinceName, 
     RemoteEmployeeRegion, 
     RemoteEmployeeExactAddress, 
      Bank, BeneficiaryName, 
      AccountNumber, 
      AccountType, 
      ContractDate, 
       ContractExpirationDate 
       FROM remoteemployees, properties 
       WHERE RemoteEmployeeID = '".$search."' OR RemoteEmployeeEmail = '".$search."' OR RemoteEmployeeFullName = '".$search."'"; 

    $query_run = $connection->query($query); 
     if($query_run->num_rows == 0) 
    { 
     exit("<center><font color='red'><strong>Sorry, No Records Found For Your Search</strong></font></center>"); 

    } ?> 

    <tr><th>R.E.ID</th><th>R.E.FullName</th><th>R.E.Password</th> 
    <th>R.E.Phone</th><th>R.E.Email</th><th>Status</th><th>More</th> 
</tr> 
<?php 
    if($connection->error) exit($connection->error); 
    while($row=$query_run->fetch_assoc()) 
    { 

?> 

<tr><td><?php echo $row['RemoteEmployeeID'] ?></td><td><?php echo $row['RemoteEmployeeFullName'] ?></td><td><?php echo $row['RemoteEmployeePassword'] ?></td> 
<td><?php echo $row['RemoteEmployeePhone'] ?></td><td><?php echo $row['RemoteEmployeeEmail'] ?></td> 

<td><a href= "More About Remote Employees.php?RemoteEmployeeID=<?php echo $row['RemoteEmployeeID'] ?>" style="color:#FFF;"><img src="../Images for admin panel/zoom.png"></a></td> 
</tr> 

<?php } 


?> 
<tr><td colspan="7"><input type="button" value="Print Current Page" onClick="window.print()" style=" font: 15px verdana; 
    text-decoration: none; 
    background-color: #EEEEEE; 
    color: #333333; 
    padding: 2px 6px 2px 6px; 
    border-top: 1px solid #CCCCCC; 
    border-right: 1px solid #333333; 
    border-bottom: 1px solid #333333; 
    border-left: 1px solid #CCCCCC; 
    cursor:pointer;"></td></tr> 
</table> 
</form> 
</body> 
</html> 
+0

你的查詢是不正確的,你應該使用查詢 – Rashid 2014-11-22 05:23:59

+0

你的錯誤發生在哪一行? – Rasclatt 2014-11-22 05:31:59

+0

122或121線 – 2014-11-22 05:35:21

回答

0

您應該檢查你執行,則查詢檢查連接錯誤消息,如果是假的後$query_run不假。如果查詢失敗,則$query_run將不是一個對象。

您也不應該使用query(),您應該使用prepare(),因爲您使用的是用戶輸入($_POST)。準備好的語句將防止數據庫被SQL注入操縱或銷燬。