This question already has an answer here:
I tried to create a PHP search (searching in a MySQL DB). The Code should post the search results down below the form. So I wrote the following:
<?php
Session_Start();
$username=$_SESSION['username'];
$password=$_SESSION['password'];
$dbname=$_SESSION['dbname'];
$servername=$_SESSION['hostname'];
/*connection test...*/
$conn = new mysqli($servername, $username, $password, $dbname);
if(!$conn){
header("Location: LogIn.php");
}
echo "verbindung erfolgreich!";
/*tabellen suche...*/
$output = '';
if (isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM patientenstamm WHERE Vorname LIKE '%$searchq%' OR Nachname LIKE '%$searchq%'");
$count = mysql_num_rows($query);
if($count == 0){
$output = 'Keine Ergebnisse gefunden!';
}else{
while($row = mysql_fetch_array($query)) {
$Vname = $row['Vorname'];
$Nname = $row['Nachname'];
$id = $row['id'];
$output .= '<div>'.$Vname.' '.$Nname.'</div>';
}
}
/* tabelleaufruf...*/
$abfrage = "SELECT * FROM patientenstamm" ;
$ergebnis = mysqli_query($conn, $abfrage);
?>
and HTML:
<!DOCTYPE html>
<html>
<head>
<title> Suchen </title>
</head>
<body>
<form method="POST" action="auflistenPatient.php">
<input type="text" id="search" name="search" placeholder="search">
<input type="submit" value="suchen">
</form>
<?php echo $output;?>
</body>
</html>
Now I'm getting an error:
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\HTML\Rechnungs Programm\auflistenPatient.php on line 55
Does anybody know whats wrong here?
Thanks!
</div>