Php 如果有其他变量问题

Php 如果有其他变量问题,php,mysql,Php,Mysql,我有两个IF-ELSE语句出错的问题,但没有第三个 注意:尝试在第51行的employees2.php中获取非对象的属性 0结果 // Pass appropriate SQL to the database $lname = htmlspecialchars($_POST["lname"]); $fname = htmlspecialchars($_POST["fname"]); $empid = htmlspecialchars($_POST["empid"]); echo "<h3

我有两个IF-ELSE语句出错的问题,但没有第三个

注意:尝试在第51行的employees2.php中获取非对象的属性 0结果

// Pass appropriate SQL to the database
$lname = htmlspecialchars($_POST["lname"]);
$fname = htmlspecialchars($_POST["fname"]);
$empid = htmlspecialchars($_POST["empid"]);

echo "<h3>Search results.</h3>";
$sqlL = "SELECT * FROM employees WHERE LAST_NAME = \"" . $lname . "\"";
$sqlF = "SELECT * FROM employees WHERE FIRST_NAME \"" . $fname . "\"";
$sqlID = "SELECT * FROM employees WHERE EMPLOYEE_ID \"" . $empid . "\""; 
$resultL = $conn->query($sqlL);
$resultF = $conn->query($sqlF);
$resultID = $conn->query($sqlID);

if ($resultF->num_rows > 0) {
    // Output data of each row
    printf("\n\t<table><th>Name</th>
                       <th>Employee ID</th>
           ");
    while ($row = $resultF->fetch_assoc()) {
        printf("\n\t<tr><td>%s%s</td>
                        <td>%s</td></tr>", 
               $row["LAST_NAME"], $row["FIRST_NAME"], $row["EMPLOYEE_ID"]);
    }

    echo "</table>\n";
    echo "<h5><strong>($resultF->num_rows) results returned.</strong></h5><br>";
} else {
    echo "0 results ";
}
//将适当的SQL传递到数据库
$lname=htmlspecialchars($_POST[“lname”]);
$fname=htmlspecialchars($_POST[“fname”]);
$empid=htmlspecialchars($_POST[“empid]”);
回显“搜索结果”;
$sqlL=“从姓氏=\”的员工中选择*。$lname.\”;
$sqlF=“从名为“.$fname.”的员工中选择*;
$sqlID=“选择*来自员工的员工ID\”.$empid.\”;
$resultL=$conn->query($sqlL);
$resultF=$conn->query($sqlF);
$resultID=$conn->query($sqlID);
如果($resultF->num_rows>0){
//每行的输出数据
printf(“\n\t名称
员工ID
");
而($row=$resultF->fetch_assoc()){
printf(“\n\t%s%s”
%s“,
$row[“姓氏”]、$row[“姓氏”]、$row[“员工ID”];
}
回音“\n”;
echo“($resultF->num_行)返回的结果。
”; }否则{ 回显“0结果”; }
尝试
而($row=mysql\u fetch\u assoc($resultF))
您在
$sqlF
$sqlID
查询->
中缺少了您的
=
,第一个\u NAME\”$fname。“\”;
/
…其中员工ID\”.$empid.\”。因此,您的查询失败,因此您的
$resultF
$resultID
将导致
非对象
显示将从OOP更改为过程式解决OPs问题吗?不起作用。现在我得到一个通知:试图获得非对象错误的属性。我是一个极端的noob。边走边研究。@JohnChaney您是否尝试过在我29分钟前提到的两个查询中添加缺少的
=
?您的查询语法无效,因此它们失败,导致出现
非object
消息。