<?php
if (isset($_POST['submit']) && isset($_POST['titel']) && isset($_POST['trainer']) && isset($_POST['ort'])&&
isset($_POST['dauer']) && $_POST['titel'] != '' && $_POST['trainer'] != '' && $_POST['ort'] != '' &&
(int)$_POST['dauer'] > 0) {
try
$db = new MySQLi('localhost', 'root', '', 'php');
echo 'Verbindung offen.<br />';
$sql = 'INSERT INTO trainings (titel, trainer, ort, dauer) VALUES (?, ?, ?, ?)';
$kommando = $db->prepare($sql);
$kommando->bind_param('sssi', $_POST['titel'], $_POST['trainer'], $_POST['ort'], $dauer);
$dauer = (int)$_POST['dauer'];
$kommando->execute();
echo 'SQL geschickt. <br />';
echo $kommando->affected_rows . ' Zeilen betroffen. <br />';
$db->close();
echo 'Verbindung zu.<br />';
} catch (Exception $e) {
echo 'Fehler: ' . htmlspecialchars($e->getMessage());
}
}
?>
- Output for 5.4.18
- Parse error: syntax error, unexpected '$db' (T_VARIABLE), expecting '{' in /in/Z2H0T on line 6
Process exited with code 255. - Output for 5.4.0 - 5.4.17
- Parse error: syntax error, unexpected '$db' (T_VARIABLE), expecting '{' in /in/KZIXc on line 6
Process exited with code 255. - Output for 5.3.0 - 5.3.27
- Parse error: syntax error, unexpected T_VARIABLE, expecting '{' in /in/KZIXc on line 6
Process exited with code 255.
preferences:
180.3 ms | 1386 KiB | 54 Q