Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Php编程错误(无法运行while循环)_Javascript_Php_Jquery_Html_Mysql - Fatal编程技术网

Javascript Php编程错误(无法运行while循环)

Javascript Php编程错误(无法运行while循环),javascript,php,jquery,html,mysql,Javascript,Php,Jquery,Html,Mysql,错误:警告:mysqli_fetch_assoc希望参数1是mysqli_result,第41行和第52行给出的整数,其中包含 请帮帮我,谢谢!!!!!sql确实从数据库中获取数据。但是,while循环仍有一些错误。这通常发生在mysqli\u查询没有正常运行时 试试这个 <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="format-dete

错误:警告:mysqli_fetch_assoc希望参数1是mysqli_result,第41行和第52行给出的整数,其中包含


请帮帮我,谢谢!!!!!sql确实从数据库中获取数据。但是,while循环仍有一些错误。

这通常发生在mysqli\u查询没有正常运行时

试试这个

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />

<?php
    session_start();

    $conn = mysqli_connect("localhost", "root", "","test");

    $product_code = $_GET['product_code'];
    $sql = "SELECT * FROM test_config WHERE product_code = '$product_code'";
    $product_list = mysqli_query ( $conn, $sql);

    if($product_list = 1)
    echo"good";
    else
    echo"bad"; 
?>
</head>

<body>

<span id="tttt"></span>
<form id="msform" method="post">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">

<?php While ($one_product = mysqli_fetch_assoc($product_list)) {?>


<li><?php echo $one_product['test_name']; ?></li>

<?php } ?>

<!-- <a href="index.html" >Start-Over</a>  -->
<span onclick="window.close()" style="float:right">Start-Over</span>
</ul>

<?php While ( $one_product = mysqli_fetch_assoc($product_list)  ) { 

        $num_test = $one_product['num_test'];
        $test_name = $one_product['test_name'];
        $images_pos = $one_product['images_pos'];
        $images_neg = $one_product['images_neg'];
        $images_inv = $one_product['images_inv'];
?>
<!-- fieldsets -->
<fieldset id="<?php $test_name; ?>" data-set="0">
<h2 class="fs-title"><?php echo "$test_name"; ?></h2>
<img src="images/<?php $images_pos; ?>"  class="case" data-case="1"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="N" class="hide">
<img src="images/<?php $images_neg; ?>"  class="case" data-case="2"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="P" class="hide">
<img src="images/<?php $images_inv; ?>"  class="case" data-case="3"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="I" class="hide">
<img src="images/skip_button.fw.png"  class="case" data-case="4"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="S" class="hide">
<br/>

<?php if ($num_test > 1) { ?>
<input type="button" name="next" class="next action-button" value="Next" />

<br/>
<?php if($num_test == 1) { ?>

<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="submit" id="submit" class="action-button" value="SAVE" />

</fieldset>
<?php }
$num_test --; ?>
<?php } }?>

</form>

</body>
</html>

我认为你的查询有错误。你能用这个替换你的代码吗?它应该向您提供一条错误消息,告诉您的查询中有什么问题。 如果我猜一下,我会说$product_代码在数据库中存储为一个整数,但在查询中使用它作为字符串

if (!$query) {
        echo 'MySQL Error: ' . mysqli_error();
        exit;
    }
如果$product\u list=1 埃科古德; 其他的 埃科巴德


不应该在那里。由于它会将$product_list转换为布尔值,因此无法在循环中运行

请检查double equal:if$product_list==1结束标记之前的if语句的语法是否需要一些工作。对于evals和缺少的部分,使用=={@blazerunner44当只有一行条件时,不需要大括号,尽管我原则上同意应该始终使用大括号。我不知道。谢谢你指出它。谢谢。我很快就会尝试。尝试从你的查询$sql=SELECT*的test_config中删除变量的引号,其中product_code=$product_代码;如果这仍然给你一个错误,请在这里发布它给你的错误。嗨,同样的问题也会发生。因为我的产品代码是一个字符串,它确实需要引号。谢谢你的建议。你的数据库中的产品代码字段也是一个字符串吗?你能在m中发布你从mysqli\u error$conn code中得到的错误吗y答案?谢谢。我很快就会尝试。我试图在里面添加代码行,但在包含代码的行中显示错误。只显示了“MySQL错误:”,错误不存在。您是否在上述代码中将变量$query更改为$product_list?不,我没有。但如果我更改它,则是相同的旧错误。
$product_list = mysqli_query( $conn, $sql) or die(mysqli_error($conn));