Dies ist Fehler:Einfügen elemets in mysql von php ich erhalte Syntaxfehler
INSERT INTO registration_table(username,password,email,phonenum)VALUES
('rahul','hdhh','[email protected]','7386627473')
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'name,password,email,phonenum)VALUES ('rahul','hdhh','[email protected]','738662747' at line 1`
<html>
<body>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$user_name = $_POST["uname"];
$password = $_POST["password"];
$email = $_POST["email"];
$phonenum = $_POST["phno"];
}
$link = mysqli_connect('localhost', 'root', '', 'test_ybf');
if (!$link) {
die('Could not connect: ' . mysqli_connect_error());
}
$sql = "INSERT INTO registration_table(user name,password,email,phonenum)VALUES ('$user_name','$password','$email','$phonenum')";
if (mysqli_query($link, $sql)) {
echo "success";
} else {
echo "error:" . $sql . "<br>" . mysqli_error($link);
}
mysqli_close($link);
?>
</body>
</html>
Passwort ist ein reserviertes Schlüsselwort. –
Platz in Spalte Name 'Benutzername' verwenden Sie es innerhalb Backtick – Saty
Beachten Sie auch, dass Ihr Code für SQL-Injektionen offen ist. Sie sollten vorbereitete Anweisungen verwenden oder zumindest der Eingabe entgehen. –