Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Błędne zapytanie do bazy- INSERT
Kochan
post
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 22.08.2006

Ostrzeżenie: (0%)
-----


Witam, mam problem z insertem z mojego kodu, wydaje mi się że jest poprawny.
Połaczenie z bazą jest OK, tabela post dodana a w niej kolumny z identycznymi nazwami.
W rezultacie po submicie mam tylko info że zapytanie niepoprawne a w bazie nie ma danych z formularza.

  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <form method="post" action="ins_post.php" enctype="multipart/form-data">
  6. <table width="600" align="center" border="5px">
  7. <tr>
  8. <td align="center" colspan="4px" ><h2> Dodaj Post</h2></td>
  9. </tr>
  10. <tr>
  11. <td>Tytul</td>
  12. <td><input type="text" name="tytul"></td>
  13. </tr>
  14. <tr>
  15. <td>Keywords</td>
  16. <td><input type="text" name="keywords"></td>
  17. </tr>
  18. <tr>
  19. <td>Zawartość</td>
  20. <td><textarea rows="25" cols="50" name="content"></textarea></td>
  21. </tr>
  22. <tr>
  23. <td>Obrazek</td>
  24. <td><input type="file" name="img"></td>
  25. </tr>
  26. <tr>
  27. <td>Autor</td>
  28. <td><input type="text" name="autor"></td>
  29. </tr>
  30. <tr>
  31. <td>Miasto</td>
  32. <td><input type="text" name="miasto"></td>
  33. </tr>
  34. <tr>
  35. <td><input type="submit" name="submit" value="Submit" /></td>
  36. </tr>
  37.  
  38. </form>
  39. </body>
  40. </html>
  41. <?php include("./config_mysql.php");
  42. if(isset($_POST['submit'])){
  43. $post_tytul = $_POST['tytul'];
  44. $post_keywords = $_POST['keywords'];
  45. $post_content = $_POST['content'];
  46. $post_data = date('d-m-y');
  47. $post_autor = $_POST['autor'];
  48. //$post_img = $_FILES['img']['name'];
  49. //$img_tmp = $_FILES['img']['tmp_name'];
  50. $post_miasto = $_POST['miasto'];
  51.  
  52. if($post_tytul=='' or $post_keywords=='' or $post_autor=='' or $post_content=='' or $post_miasto=='')
  53. {
  54. echo("<script>confirm('Wpisz wartości!')</script>");
  55. exit();
  56. }
  57. else {
  58. //move_uploaded_file($img_tmp,"/img/$post_img");
  59. // kolumny wpisane bez `- również zapytanie niepoprawne
  60. $insert_query = "INSERT INTO post (`post_tytul`,`post_autor`,`post_keywords`,`post_content`,`post_data`,`post_
    miasto`) VALUES ('$post_tytul','$post_autor'.'$post_keywords','$post_content','$post_data','$post_miasto')"
    ;
  61. if(mysql_query($insert_query) or die("Zapytanie niepoprawne"));{
  62. echo ("<center><h1>Dodano wpis !</h1></center>");
  63. }
  64.  
  65. }
  66. }
  67.  
  68.  
  69.  
  70. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.09.2025 - 06:44