Добрый вечер!!! подскажите пожалуйста в чём ошибка?
Notice: Undefined variable: id in C:\xampp\htdocs\PhpProject1\genre_add.php on line 28
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 '' at line 3
<html>
<head>
<meta charset="UTF-8">
<Title>Кукольный театр</Title>
</head>
<Body>
<Center>
<H1>Кукольный театр</H1>
</Center>
<a href="http://localhost/PhpProject1/">Назад</a>
<H2>Новый жанр</H2>
<?Php
$db=new mysqli('localhost','root','','theatres')or die($db->error);
if ($_SERVER['REQUEST_METHOD']=='POST') {
$name = ($_POST['name']);
if ($_POST['id']) {
$query=" UPDATE `genre`
SET `name`='$name'
WHERE `id`=$id";
} else {
$query="
INSERT INTO `genre`
SET `name`= '$name'";
}
$result= $db->query($query) or die($db->error);
hearder("location:
http://localhost/PhpProject1/genre.php");}
if (isset($_GET['id'])) {
$id =$_GET['id'];
$query = " SELECT *
FROM `genre`
WHERE `id`=$id";
$result = $db->query($query) or die ($db->error);
$row=$result->fetch_array();
}
else {
$row['name']="";
$row['id']=0;
}
?>
<form method="POST">
<label>Название жанра:</label><br />
<input type="text" name="name" value="<?=$row['name']?>">
<input type="hidden" name="id" value="<?=$row['id']?>">
<input type="submit"><br />
</form>
</body>
</html>