2017-03-18 49 views
-4

警告:mysql_fetch_array()期望参数1是资源,布尔值在C中给出:\ XAMPP \ htdocs中\工资\工资\ home_employee.php线路7警告:mysql_fetch_array()期望参数1是资源,布尔在第7行给出C: xampp htdocs payroll payroll home_employee.php

<?php 

include("auth.php"); //include auth.php file on all secure pages 
include("add_employee.php"); 
$query = ("SELECT * FROM deductions WHERE deduction_id='1'"); 
$result = mysql_query($query); 
while($row = mysql_fetch_array($result)); 
{ 

     $phil = $row["philhealth"]; 
     $bir = $row["bir"]; 
     $gsis = $row["gsis"]; 
     $love = $row["pag_ibig"]; 
     $loans = $row["loans"]; 
} 
?> 
+1

使用'mysqli',而不是'mysql' –

+0

*闻SQLI漏洞*'deduction_id ='1'' – revo

+0

删除分号后而($行= mysql_fetch_array($结果)); –

回答

0

使用mysqli的连接。试试这个

$link = mysqli_connect($host, $username, $password, $dbname); 
$query = "SELECT * FROM deductions WHERE deduction_id='1'"; 
$result = mysqli_query($query); 
foreach ($result as $key => $row){ 
    $phil = $row["philhealth"]; 
    $bir = $row["bir"]; 
    $gsis = $row["gsis"]; 
    $love = $row["pag_ibig"]; 
    $loans = $row["loans"]; 
} 
相关问题