gpt4 book ai didi

php & mysql 数据库拉取错误

转载 作者:行者123 更新时间:2023-11-29 08:07:48 24 4
gpt4 key购买 nike

你好,我有一个网站,我正在用 php 编码。我附有一个数据库。我试图让它将数据从数据库读入页面。我将数据库分成几个表。我以为我已经正确完成了代码,但我不断收到以下错误代码:

Warning: mysqli_query() expects parameter 1 to be mysqli, integer given in C:\xampp\htdocs\stadium\alpha\a.php on line 13

Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\stadium\alpha\a.php on line 14

Notice: Trying to get property of non-object in C:\xampp\htdocs\stadium\alpha\a.php on line 15

Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\stadium\alpha\a.php on line 16

我已经尝试研究这个有一段时间了,但我无法弄清楚这一点。我的数据拉取和显示代码如下:

$sql = "SELECT colConferenceName.tblConference, colSchoolName.tblSchool, colClass.tblSchool, colSurfaceName.tblSurface, colSurfaceCompany.tblSurface, colStadiumName.tblStadium, colAddress.tblStadium, colCity.tblStadium, colRegion.tblStadium, colCounty.tblStadium, colCapacity.tblStadium, colSurfaceYear.tblSurface FROM tblStadium, tblConference, tblSurface, tblSchool WHERE tblConference.colConferenceID = tblSchool.colConferenceID AND tblSurface.colSurfaceID = tblStadium.colSurfaceID AND tblStadium.colStadiumID = tblStadiumSchool.colStadiumID AND tblSchool.colSchoolID = tblStadiumSchool.colSchoolID AND colStadiumName LIKE 'A%' ORDER BY colSchoolName";
$schoolinfo = mysqli_query($conn,$sql);
mysqli_fetch_all($schoolinfo,MYSQLI_ASSOC);
while (!$schoolinfo->EOF){ //looping through the recordset (until End Of File)
while ($row = mysqli_fetch_all($schoolinfo,MYSQLI_ASSOC)){
echo '<p>School Name: ' . $row['colSchoolName'] . '</br>Conference: ' . $row['colConferenceName'] . '</br>Class: ' . $row['colClass'] . '</br>Stadium Name: ' . $row['colStadiumName'] . '</br>Address: ' . $row['colAddress'] . '</br>City: ' . $row['colCity'] . '</br>County: ' . $row['colCounty'] . '</br>Region: ' . $row['colRegion'] . '</br>Capacity: ' . $row['colCapacity'] . '</br>Surface Type: ' . $row['colSurfaceName'] . '</br>Surface Company: ' . $row['colSurfaceCompany'] . '</br>Year Installed: ' . $row['colSurfaceYear'] . '</p>';
}
}

您能为我提供的任何帮助都会很棒。提前致谢。

至于连接,它是在单独的连接文件中完成的。它拉取的方式是 $conn = require('xxx_xxx.xxx');我原则上询问输出以及如何修复编码错误。我 xxx 断开连接,因为我不希望人们有权访问该文件名。我还与此进行了大约 80 到 100 个连接,因此使用一个文件进行连接比编辑每个 php 文件的连接部分更有意义。另外,我发现这样可以提高安全性。

最佳答案

我没有看到您连接到 mysql 的时间点。尝试mysqli_connect

$conn = mysqli_connect('<your-host>','<your-username>','<your-password>','<your-databasename>').

关于php & mysql 数据库拉取错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22378913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com