得到mysqli_fetch_assoc()错误,无法以某种方式解决它

时间:2015-09-17 08:49:23

标签: php mysql

我收到了这个错误:

  

警告:mysqli_fetch_assoc()期望参数1为mysqli_result,布尔值在

中给出

我自己无法解决,所以希望你们能帮助我。

<?php
session_start();
include 'dbcon.php';
$page = 'index.php';
if (isset($_GET['toevoegen'])) {
  $query ='SELECT partnr, hoeveelheid FROM producten WHERE partnr='.$_GET['toevoegen'];
  $result = mysqli_query($connectie, $query);
  while ($result_row = mysqli_fetch_assoc($result)) {
    if ($result_row['hoeveelheid']!=$_SESSION['winkelwagen_'.$_GET['toevoegen']]) {
      $_SESSION['winkelwagen_'.$_GET['toevoegen']]+='1';
    }
  }
} 
?>

2 个答案:

答案 0 :(得分:0)

您的查询未关闭

<script>

它应该关闭或给$ _GET

的变量

实施例: 这是对代码的简单修改,或者尝试其他代码

'SELECT partnr, hoeveelheid FROM producten WHERE partnr='.$_GET['toevoegen'];

试用此代码

'SELECT partnr, hoeveelheid FROM producten WHERE partnr="'.$_GET['toevoegen'].'"';

答案 1 :(得分:0)

试试这个

<?php
session_start();
include 'dbcon.php';
$page = 'index.php';
$toevoegen = $_GET['toevoegen'];
if(isset($_GET['toevoegen'])){
$query ="SELECT partnr, hoeveelheid FROM producten WHERE partnr='$toevoegen'";
$result = mysqli_query($query);
 while($result_row = mysqli_fetch_assoc($result)){
    if($result_row['hoeveelheid']!=$_SESSION['winkelwagen_'.$_GET['toevoegen']]){
        $_SESSION['winkelwagen_'.$_GET['toevoegen']]+='1';
    }
 }
} 
?>