Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Dobry formularz a nie dziala:)
Bojakki
post
Post #1





Grupa: Zarejestrowani
Postów: 379
Pomógł: 0
Dołączył: 18.08.2004

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


Zrobilem formularz, ktory ma wysylac dane do bazy mysql:

  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. if (isset($_POST['sub'])) 
  6.  { 
  7.  mysql_query("INSERT INTO gb_recenzje VALUES('$_GET[wsk]','$_POST[tytul]','$_POST[recenzja]','$_POST[autor]'"); 
  8.  } 
  9. echo '<b>Dodaj recenzję</b><br><br> 
  10. <center> 
  11. Tytul recenzji:</font><br> 
  12. <form method=POST action="game.php?wsk='.$_GET[wsk].'&act=recenzje"> 
  13. <input maxLength="128" size="48" name="tytul"><br></font> 
  14. Opis:<br> 
  15. <textarea style="BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: black; BACKGROUND: #ffffff; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: black; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: black" name="recenzja" rows="7" cols="49" type="text" value size="1000" maxlength="1000"></textarea><br> 
  16. Autor recenzji:</font><br> 
  17. <input maxLength="128" size="48" name="autor"><br> 
  18. <input type=hidden name=sub> 
  19. <input type="submit" value="Dodaj do bazy !"><br><br></center> 
  20. </form> 
  21. ';
  22. ?>


w bazie stworzylem tabele o nazwie gb_recenzje z polami: id, tyul, recenzja, autor.

Po wcisnieciu przycisku Dodaj do bazy, nie wyskakuje zaden blad, tylko powtornie laduje sie strona z formularzem, wchodze dophpmyadmin i patrze czy cos sie dodalo, ale nic sie nie dodaje.

Meczylem sie z 3h, ale problem jak dla mnie nie do przejscia... Nie weim moze zle tabele stworzylem:/

Ps. dane do bazy (login, haslo, nazwa bazy) sa w pliku config.php i sa dobre bo inne formularze mi dzialaja.


--------------------
Go to the top of the page
+Quote Post
strife
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Może masz problem z zapytaniem dodaj sobie obsługę błędów mysql, mianowicie mysql_error" title="Zobacz w manualu php" target="_manual pod tym zapytaniem dodaj:
  1. <?php
  2.  
  3. // ...
  4. // ...
  5.  
  6. ?>


Pozdrawiam!


--------------------
Go to the top of the page
+Quote Post
Bojakki
post
Post #3





Grupa: Zarejestrowani
Postów: 379
Pomógł: 0
Dołączył: 18.08.2004

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


Wyskoczylo mitakie cos:

Cytat
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


Nie wiem czyw dobre meijsce wrzucilem ten kod, dalem go na kocnu:

  1. <?php
  2. ....
  3.  <input type=hidden name=sub>
  4. <input type="submit" value="Dodaj do bazy !"><br><br></center>
  5. </form>
  6. ';
  7. echo mysql_error();
  8. ?>


--------------------
Go to the top of the page
+Quote Post
-Gość_lukas1-
post
Post #4





Goście







Zmień linię:
  1. <?php
  2.  mysql_query("INSERT INTO gb_recenzje VALUES('$_GET[wsk]','$_POST[tytul]','$_POST[recenzja]','$_POST[autor]'");
  3. ?>

na:
  1. <?php
  2.  mysql_query("INSERT INTO gb_recenzje VALUES('".$_GET['wsk']."','".$_POST['tytul']."','".$_POST['recenzja']."','".$_POST['autor']."')");
  3. ?>
Go to the top of the page
+Quote Post
vtuner
post
Post #5





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


ten kod miales dac pod tym
  1. <?php
  2. mysql_query("INSERT INTO gb_recenzje VALUES('$_GET[wsk]','$_POST[tytul]','$_POST[recenzja]','$_POST[autor]'"); 
  3. ?>

czyli ma to wygladac tak
  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. if (isset($_POST['sub'])) 
  6.  { 
  7.  mysql_query("INSERT INTO gb_recenzje VALUES('$_GET[wsk]','$_POST[tytul]','$_POST[recenzja]','$_POST[autor]'"); 
  8.  } 
  9. echo '<b>Dodaj recenzję</b><br><br> 
  10. <center> 
  11. Tytul recenzji:</font><br> 
  12. <form method=POST action="game.php?wsk='.$_GET[wsk].'&act=recenzje"> 
  13. <input maxLength="128" size="48" name="tytul"><br></font> 
  14. Opis:<br> 
  15. <textarea style="BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: black; BACKGROUND: #ffffff; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: black; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: black" name="recenzja" rows="7" cols="49" type="text" value size="1000" maxlength="1000"></textarea><br> 
  16. Autor recenzji:</font><br> 
  17. <input maxLength="128" size="48" name="autor"><br> 
  18. <input type=hidden name=sub> 
  19. <input type="submit" value="Dodaj do bazy !"><br><br></center> 
  20. </form> 
  21. ';
  22. ?>


Ten post edytował vtuner 11.11.2005, 15:18:13
Go to the top of the page
+Quote Post
-Guest-
post
Post #6





Goście







A najlepiej to napisz to tak:

  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. if (isset($_POST['sub'])) 
  6.  { 
  7.  mysql_query("INSERT INTO gb_recenzje VALUES('".$_POST['wsk']."','".$_POST['tytul']."','".$_POST['recenzja']."','".$_POST['autor']."')");
  8.  } 
  9. echo "<b>Dodaj recenzję</b><br><br>
  10.  <center>
  11.  Tytul recenzji:</font><br>
  12.  <form method=POST action="game.php">
  13.  <input type=hidden name=sub>
  14.  <input type=hidden name=wsk value="".$_GET['wsk']."">
  15.  <input type=hidden name=act value="recenzje">
  16.  <input maxLength="128" size="48" name="tytul"><br></font>
  17.  Opis:<br>
  18.  <textarea style="BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: black; BACKGROUND: #ffffff; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: black; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: black" name="recenzja" rows="7" cols="49" type="text" value size="1000" maxlength="1000"></textarea><br>
  19.  Autor recenzji:</font><br>
  20.  <input maxLength="128" size="48" name="autor"><br>
  21.  <input type="submit" value="Dodaj do bazy !"><br><br></center>
  22.  </form>";
  23.  
  24. ?>
Go to the top of the page
+Quote Post
Bojakki
post
Post #7





Grupa: Zarejestrowani
Postów: 379
Pomógł: 0
Dołączył: 18.08.2004

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


Cytat(Gość_lukas1 @ 2005-11-11 14:17:18)
Zmień linię:
  1. <?php
  2.    mysql_query("INSERT INTO gb_recenzje VALUES('$_GET[wsk]','$_POST[tytul]','$_POST[recenzja]','$_POST[autor]'");
  3. ?>

na:
  1. <?php
  2.    mysql_query("INSERT INTO gb_recenzje VALUES('".$_GET['wsk']."','".$_POST['tytul']."','".$_POST['recenzja']."','".$_POST['autor']."')");
  3. ?>

Jestes Bogiem;)

Juz dziala.


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 19.08.2025 - 14:32