你好,我有一個網站,我在PHP編碼。我有一個數據庫附加到它。我試圖從數據庫中讀取數據到頁面中。我把數據庫分成幾個表格。我以爲我有代碼得當,但我一直在得到以下的錯誤代碼:php和mysql數據庫拉錯誤
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文件的連接部分更有意義。另外我發現它可以有更多的安全性。
你在哪裏設置你的'$ conn' – CodeBird
$ conn = mysqli_conect()..... –
**** connect **** mysqli_connect double n – CodeBird