Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL]Błąd w Update do SQL
eurosoft
post 7.01.2011, 18:33:12
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 5.11.2010

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


Witam, mam taki kod jak poniżej a problem polega na tym że nie wpisuje mi zmian do tabeli, proszę o pomoc w odnalezieniu baga...
  1. <?php
  2. include 'config.php';
  3. $tabela = 'book';
  4. $tabela1 = 'shott';
  5.  
  6.  
  7.  
  8.  
  9. $sql="SELECT id_shot, animals, ilosc, ilosc_shot FROM $tabela1 WHERE id_book=70";
  10. $res=mysql_query($sql);
  11. $num=mysql_num_rows($res);
  12.  
  13. if($num>0)
  14. {
  15. while($r=mysql_fetch_array($res))
  16. {
  17. <form action="xxx.php" method="post">
  18. <input type="hidden" name="a" value="save" />
  19. <input type="hidden" name="id_book" value="'.$id_book.'" />
  20.  
  21. <select name="animals">
  22. <option value='.$r[animals].'">'.$r[animals].'</option>
  23. <option value=""></option>
  24. <option value="Koń">Koń</option>
  25. <option value="Papuga">Papuga</option>
  26. <option value="Słoń">Słoń</option>
  27. </select>
  28. <select name="ilosc">
  29. <option value='.$r[ilosc].'">'.$r[ilosc].'</option>
  30. <option value=""></option>
  31. <option value="01:00">01.00</option>
  32. <option value="02:00">02.00</option>
  33. <option value="03:00">03.00</option>
  34. </select>
  35. </br></br>
  36.  
  37.  
  38. <input type="submit" value="Aktualizuj dane"/>
  39. </form>';
  40. }
  41. }
  42.  
  43. elseif($a == 'save') {
  44. $animals = trim($_POST['animals']);
  45. $ilosc = trim($_POST['ilosc']);
  46. $id_shot = trim($_POST['id_shot']);
  47.  
  48. $update=mysql_query("UPDATE shott SET animals='$animals', ilosc='$ilosc', WHERE id_shot=id_shot")
  49. or die('Błąd zapytania');
  50. echo 'Zaktualizowano';
  51. }
  52.  
  53.  
  54.  
  55.  
  56. ?>

dla wyjaśnienia, w tabeli są trzerekordy o identycznym Id_book, różnym id_shot różnej wartości animals oraz ilosc stąd pętla w wyświetlaniu wyników
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
amii
post 7.01.2011, 19:25:47
Post #2





Grupa: Zarejestrowani
Postów: 728
Pomógł: 76
Dołączył: 12.06.2009

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


Popraw update na to co poniżej brakowało dolarka przy zmiennej
$update=mysql_query("UPDATE shott SET animals='$animals', ilosc='$ilosc', WHERE id_shot=$id_shot")
or die('Błąd zapytania');


--------------------
gry flash online
Dobry hosting i tanie odnowienia domen firma: masternet.
Zarabianie bez wysiłku na domenach bez ruchu: prolink.
Go to the top of the page
+Quote Post
eurosoft
post 7.01.2011, 22:08:57
Post #3





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 5.11.2010

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


sad.gif niestety to chyba coś jeszcze jest skopane.....
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:06