Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <html>
  2. <head>
  3. <html lang="ru">
  4. <meta charset="UTF-8">
  5. </head>
  6. </html>
  7.  
  8. <?php
  9. $host = '';
  10. $user = '';
  11. $pass = '';
  12. $db_name = '';
  13. $link = mysqli_connect($host, $user, $pass, $db_name);
  14. mysqli_set_charset($link, 'utf8');
  15.  
  16. if (!$link) {
  17. echo 'Не могу соединиться с БД. Код ошибки: ' . mysqli_connect_errno()
  18. . ', ошибка: ' . mysqli_connect_error();
  19. exit;
  20. }
  21.  
  22. $id = $_POST['id'];
  23. $title = $_POST['title'];
  24. $text = $_POST['text'];
  25. $code = $_POST['code'];
  26.  
  27. if (isset($_POST["button"])) {
  28. $sql = mysqli_query($link, "INSERT INTO `python` (`id`, `title`, `text`,
  29. `code`) VALUES ($id, $title, $text, $code)");
  30. if ($sql) {
  31. echo '<p>Данные успешно добавлены в таблицу.</p>';
  32. echo '<meta http-equiv="refresh" content="0; url=../add">';
  33. } else {
  34. echo '<p>Произошла ошибка: ' . mysqli_error($link) . '</p>';
  35. }
  36. }
  37. ?>
  38.  
  39. Произошла ошибка: You have an error in your SQL syntax; check the manual
  40. that corresponds to your MariaDB server version for the right syntax to
  41. use near 'test():
  42. print('Test')
  43. test())' at line 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement