我必須爲學校做一個網站。它需要與數據庫鏈接。在localhost
一切正常和作品,但是當我試圖把它上傳學校的主機上,我得到這個錯誤:未定義的索引PHP放置在主機上
Notice: Undefined index: vragen in /mnt/studentenhomes/arnaud.gandibleux/public_html/datamanagement/index.php on line 44
我無法找到解決辦法
的index.php
<div id="tekst">
<table align='center'>
<?php
//if (isset($_GET['vragen'])){
if ($_GET['vragen'] === 'Alleclubs') {
getclubs();
} elseif ($_GET['vragen'] === 'ledenvjf') {
getVJFleden();
echo "test";
} elseif ($_GET['vragen'] === 'ledenffbj') {
getFFBJleden();
}
elseif (isset($_GET['clubnr'])) {
getLedenPerClubEnID($_GET['clubnr']);
}
else{
getclubs();
}
// }
?>
</table>
Crud.php
function getVJFleden() {
global $mysqli;
$result = $mysqli->query("SELECT * FROM Leden l JOIN Clubs c ON l.clubnr = c.clubnr join Bonden b
ON b.ID_bond = c.ID_bond LEFT JOIN adressen a ON a.ID_adress = l.ID_adress WHERE b.naam_bond = 'VJF';");
if ($result) {
if ($result->num_rows > 0) {
echo"<caption>Alle leden VJF</caption>";
echo "<th>Voornaam</th><th>achternaam</th><th>leeftijd</th><th>Kye</th><th>adress</th>";
while ($leden = $result->fetch_object()) {
echo "<tr><td>$leden->lid_voornaam</td> ";
echo "<td>" . $leden->lid_achternaam . "</td> ";
echo "<td>" . $leden->lid_leeftijd . "</td> ";
echo "<td>" . $leden->kye . "</td> ";
echo "<td>" . $leden->straatnaam . " " . $leden->huisnummer . " " . $leden->postcode . " " . $leden->gemeente . "</td> ";
echo "<td><form id='update' action='update.php' method='POST'>
<input type='hidden' name='id' value='" . $leden->ID_lid . "'/>
<input type='hidden' name='clubnr' value='" . $_GET['clubnr'] . "'/>
<input type='image' src='update.png' alt='Update' width='22' height='22'>
</form>
<form id='delete' action='deleteLid.php' method='POST'>
<input type='hidden' name='id' value='" . $leden->ID_lid . "'/>
<input type='image' src='delete.png' alt='detele' width='22' height='22'>
</form></td> ";
}
}
}
$mysqli->close();
}
function getFFBJleden() {
global $mysqli;
#, Adressen a
#AND l.ID_adress = a.ID_adress
$result = $mysqli->query("SELECT * FROM Leden l JOIN Clubs c ON l.clubnr = c.clubnr join Bonden b ON b.ID_bond = c.ID_bond LEFT JOIN adressen a ON a.ID_adress = l.ID_adress WHERE b.naam_bond = 'FFBJ';");
if ($result) {
if ($result->num_rows > 0) {
echo"<caption>Alle leden VJF</caption>";
echo "<th>Voornaam</th><th>achternaam</th><th>leeftijd</th><th>Kye</th><th>adress</th>";
while ($leden = $result->fetch_object()) {
echo "<tr><td>$leden->lid_voornaam</td> ";
echo "<td>" . $leden->lid_achternaam . "</td> ";
echo "<td>" . $leden->lid_leeftijd . "</td> ";
echo "<td>" . $leden->kye . "</td> ";
echo "<td>" . $leden->straatnaam . " " . $leden->huisnummer . " " . $leden->postcode . " " . $leden->gemeente . "</td> ";
echo "<td><form id='update' action='update.php' method='POST'>
<input type='hidden' name='id' value='" . $leden->ID_lid . "'/>
<input type='hidden' name='clubnr' value='" . $_GET['clubnr'] . "'/>
<input type='image' src='update.png' alt='Update' width='22' height='22'>
</form>
<form id='delete' action='deleteLid.php' method='POST'>
<input type='hidden' name='id' value='" . $leden->ID_lid . "'/>
<input type='image' src='delete.png' alt='detele' width='22' height='22'>
</form></td> ";
}
}
}
$mysqli->close();
}
您註釋掉一個行可以防止這個錯誤 –
由於您正在訪問'$ _GET ['vragen']',並且'$ _GET'數組不包含關鍵字'vragen',因爲您沒有在URL中提供它。 – h2ooooooo