Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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
Php 尝试回显SQL行时,什么都没有?_Php_Mysql - Fatal编程技术网

Php 尝试回显SQL行时,什么都没有?

Php 尝试回显SQL行时,什么都没有?,php,mysql,Php,Mysql,所以我设法将mysql数据库连接到我的网站,并尝试回显行值,但当我这样做时,我什么也得不到,甚至没有错误,只有一个空白点 //GET CITY RESOURCES $query = "SELECT lumber, clay, iron, crop FROM resources WHERE id = '$cityresourcesid'"; $result = mysqli_query($conn, $query); $row = mysqli_fetch_assoc($result); $

所以我设法将mysql数据库连接到我的网站,并尝试回显行值,但当我这样做时,我什么也得不到,甚至没有错误,只有一个空白点

//GET CITY RESOURCES

$query = "SELECT lumber, clay, iron, crop FROM resources WHERE id = '$cityresourcesid'";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);


$lumber = $row['lumber'];
$clay = $row['clay'];
$iron = $row['iron'];
$crop = $row['crop'];
然后我试着在页面上回应它

<div class="resources">
    <h3>Production per hour:</h3>
    <?php
        echo "Lumber: ".$lumber;
    ?>
</div>

每小时产量:
这就是我得到的:


奇怪的是它没有给我任何错误?当我写这句话时,“lumber”列中的值是500。

如果您的id
$cityresources
是一个整数,则不应使用引号

"SELECT lumber, clay, iron, crop FROM resources WHERE id =$cityresourcesid";
对于调试,请确保使用
var\u dump($row)在
$row
中有一个正确的值


如果没有正确的结果检查数据库中的数据

如果id
$cityresources
是整数,则不应使用引号

"SELECT lumber, clay, iron, crop FROM resources WHERE id =$cityresourcesid";
对于调试,请确保使用
var\u dump($row)在
$row
中有一个正确的值

如果没有对数据库中的数据进行正确的结果检查,则结果仍然相同(无),结果仍然相同(无)