php报错误的原因以及解决办法

it2023-05-02  70

示例一: 

 

原因:第二行前面不能有空格; 

解决:去掉空格就可以了;

示例二: 

<?php require 'conn.php'; //连接数据库 $sql="SELECT * FROM Downloads"; $result = mysqli_query($sql,$link); if(mysqli_num_rows($result)){ while($row=mysqli_fetch_assoc($result)){ $data[] = array( 'id' => $row['id'], 'file' => $row['filename'], 'downloads'=> $row['downloads'] ); } echo json_encode($data); } ?>

报错:

解决方法:把$result = mysqli_query($sql,$link); 换成$result = mysqli_query($link,$sql); 就可以了;

参考一:https://blog.csdn.net/sinat_36188088/article/details/104940880

参考二:http://blog.sciencenet.cn/blog-97949-1093619.html

 
最新回复(0)