PHP给了我这个错误:
解析错误:语法错误,第141行的C:\ xampp \ htdocs \ sitesld \ view.php中的文件意外结束。
你能告诉我错误在哪里以及如何修复它们?
由于
代码(关于MySQL表查看器脚本,下拉列表包含数据库的表名):
<?php
require ("includes/config.php");
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); }
$nomeutente=$_SESSION['username'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Visualizza Voti</title>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<div class="container">
<p align="right">Ciao, <?php echo $nomeutente; ?><br>
<a href='logout.php'class="waves-effect waves-light btn"><i class="material-icons left">power_settings_new</i>Logout</a></p>
<div class="fixed-action-btn">
<a class="btn-floating btn-large red"><i class="large material-icons">add</i>Aggiungi</a>
<ul>
<li><a href="new_voto.php" class="btn-floating blue"><i class="material-icons">note_add</i></a>Aggiungi voto</li>
<li><a href="new_materia.php" class="btn-floating yellow darken-1"><i class="material-icons">class</i></a>Aggiungi Materia</li>
</ul>
</div>
<form method="get" action="">
Visualizza voti di:
<div class="input-field inline">
<?php
// load database values
require 'connect-db.php';
// connect to database
$conn = new mysqli($server, $user, $pass, $db);
if ($conn->connect_error) die("Connection failed: ".$conn->connect_error);
// perform query
$sql = "show tables LIKE '$nomeutente%'";
$result = $conn->query($sql) or die($conn->error);
if (isset($_GET['materia'])) {
$mat_sel=$_GET['materia'];
// start dropdown select
echo "<select name='materia' value='$mat_sel'>";
echo "<option value='allmaterie'>Tutte le materie</option>";
// for each table in database create an entry
while ($row = $result->fetch_assoc()) {
$table = $row["Tables_in_members ($nomeutente%)"];
$mat=ucfirst(substr($table, strpos($table, "_") + 1));
echo "<option value='$table'>$mat</option>";
}
echo "</select>";
?>
</div>
<script>
$(document).ready(function() {
$('select').material_select();
});
</script>
<button class="btn waves-effect waves-light" type="submit" name="action">Visualizza
<i class="material-icons left">search</i>
</button>
</form>
<br><br>
<?php
// identifica se è stata selezionata una materia o no
if (isset($_GET['materia'])) {
$allmaterie=False;
if ($_GET['materia']=='allmaterie') {
$allmaterie=True;
}
}
else {
$allmaterie=True;
}
// visualizza i dati in tabella
echo "<button class='waves-effect waves-light btn' type='button' disabled><i class='material-icons left'>search</i>Visualizza Tutto</button> | <a class='waves-effect waves-light btn' href='view-paginated.php?page=1'><i class='material-icons left'>find_in_page</i>Visualizza impaginato</a>";
echo "<br><br>";
echo "<table class='centered striped responsive-table' border='1' cellpadding='10'>";
echo "<tr> <th>Voto</th> <th>Data</th> <th>Materia</th> <th>Peso</th> <th>Descrizione</th></tr>";
if ($allmaterie=True) {
$sql = "show tables LIKE '$nomeutente%'";
$result = $conn->query($sql) or die($conn->error);
while ($row = $result->fetch_assoc()) {
$row_result=$row["Tables_in_members ($nomeutente%)"];
$result = mysqli_query($conn,"SELECT * FROM '$row_result'")
or die(mysqli_error($connection));
// loop tra i risultati della query del database, visualizzandoli in tabella
while($row = mysqli_fetch_array( $result )) {
// emissione del contenuto di ogni riga in una tabella
echo "<tr>";
echo '<td>' . $row['voto'] . '</td>';
echo '<td>' . $row['data'] . '</td>';
echo '<td>' . $row['materia'] . '</td>';
echo '<td>' . $row['peso'] . '%</td>';
echo '<td>' . $row['descrizione'] . '</td>';
echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $row['id'] . '><i class="material-icons left">mode_edit</i>Modifica</a></td>';
echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $row['id'] . '&materia='.$row['materia'].'><i class="material-icons left">delete</i>Elimina</a>';
echo "</tr>";
}
// chiude la tabella
echo "</table>";
}
}
else {
$materia=$_GET['materia'];
$result = mysqli_query($connection, "SELECT * FROM $materia")
or die(mysqli_error($connection));
// loop tra i risultati della query del database, visualizzandoli in tabella
while($row = mysqli_fetch_array( $result )) {
// emissione del contenuto di ogni riga in una tabella
echo "<tr>";
echo '<td>' . $row['voto'] . '</td>';
echo '<td>' . $row['data'] . '</td>';
echo '<td>' . $row['materia'] . '</td>';
echo '<td>' . $row['peso'] . '%</td>';
echo '<td>' . $row['descrizione'] . '</td>';
echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $row['id'] . '><i class="material-icons left">mode_edit</i>Modifica</a></td>';
echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $row['id'] . '&materia='.$row['materia'].'><i class="material-icons left">delete</i>Elimina</a>';
echo "</tr>";
}
// chiude la tabella
echo "</table>";
}
?>
</div>
</body>
</html>
由于