This question already has answers here:
How can I get useful error messages in PHP?
                                
                                    (42个答案)
                                
                        
                        
                            mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?
                                
                                    (1个答案)
                                
                        
                                9个月前关闭。
            
                    
结果是黑屏。

php&Javascript代码

<?php
$con = mysqli_connect($db_host,$db_user,$db_passwd,$db_name);

if(mysqli_connect_errno($con)){
  echo "no database  " . mysqli_connect_error();
}

mysqli_set_charset($con, "utf8");

$result = mysqli_query($con, "select * from Market");

$n = 1;
while($row = mysqli_fetch_array($result)){ ?>
  var positions = [
      {
          latlng: new daum.maps.LatLng(
            <?= $row['lat']; ?>, <?= $row['lon']; ?>
          )
      }
<?php $n++;
}
?>


不使用mysql插入经度和纬度时的普通代码

var positions = [
    {
        latlng: new daum.maps.LatLng(33.450705, 126.570677)
    }
];


错误消息未显示在结果窗口中,并且显示空白屏幕。

最佳答案

在您的php代码的开头添加此代码


ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);


确保“市场”表中至少有一行。
在mysqli_query之后添加var_dump(mysqli_error($con));并进行
确保没有错误。

10-05 21:15
查看更多