Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Dane nie pojawiają się w bazie
$_GET['Kuba']
post 20.02.2011, 17:23:37
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Witam, mam plik generate.php
  1. <?php
  2. /*******************************************
  3. * Name: generate.php
  4. *******************************************/
  5.  
  6. require("includes/db.php");
  7. connection();
  8. $_1lvl = $_POST['1lvl'];
  9. $_2lvl = $_POST['2lvl'];
  10. $_3lvl = $_POST['3lvl'];
  11. $_4lvl = $_POST['4lvl'];
  12. $_5lvl = $_POST['5lvl'];
  13. $_6lvl = $_POST['6lvl'];
  14. $_7lvl = $_POST['7lvl'];
  15. $_8lvl = $_POST['8lvl'];
  16. $_9lvl = $_POST['9lvl'];
  17. $_10lvl = $_POST['10lvl'];
  18. $_11lvl = $_POST['11lvl'];
  19. $_12lvl = $_POST['12lvl'];
  20. $_13lvl = $_POST['13lvl'];
  21. $_14lvl = $_POST['14lvl'];
  22. $_15lvl = $_POST['15lvl'];
  23. $_16lvl = $_POST['16lvl'];
  24. $_17lvl = $_POST['17lvl'];
  25. $_18lvl = $_POST['18lvl'];
  26. $_txt = $_POST['txt'];
  27.  
  28. $insert = "INSERT INTO admiral (ID, 1lvl, 2lvl, 3lvl, 4lvl, 5lvl ,6lvl, 7lvl, 8lvl, 9lvl, 10lvl ,11lvl, 12lvl, 13lvl, 14lvlv, 15lvl, 16lvl, 17lvl, 18lvl, txt) VALUES('$id','$_1lvl','$_2lvl','$_3lvl','$_4lvl','$_5lvl','$_6lvl','$_7lvl','$_8lvl','$_9lvl','$_10lvl','$_11lvl','$_12lvl','$_13lvl','$_14lvl','$_15lvl','$_16lvl','$_17lvl','$_18lvl','$_txt')";
  29. $do = "mysql_query('$insert')";
  30. ?>

i index.php
  1. <html>
  2. <head>
  3. <link rel="stylesheet" href="style.css" type="text/css">
  4. <script language="javascript" type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
  5. <script src="js/jquery-1.4.4.min.js"></script>
  6. <script src="js/jquery-ui-1.8.9.custom.min.js"></script>
  7. <script>
  8. $(document).ready(function() {
  9. $("#accordion").accordion();
  10. });
  11. </script>
  12. <title>Admiral Build
  13. </title>
  14. </head>
  15. <body><center>
  16. <img src="images/header.jpg"/>
  17. <div id="accordion">
  18. <h3><a href="#">Skills</a></h3>
  19. <div height="600">
  20. <form action="generate.php" method="post">
  21. <table>
  22. <tr>
  23. <td>Ability</td>
  24. <td width="20">&nbsp;1</td>
  25. <td width="20">&nbsp;2</td>
  26. <td width="20">&nbsp;3</td>
  27. <td width="20">&nbsp;4</td>
  28. <td width="20">&nbsp;5</td>
  29. <td width="20">&nbsp;6</td>
  30. <td width="20">&nbsp;7</td>
  31. <td width="20">&nbsp;8</td>
  32. <td width="20">&nbsp;9</td>
  33. <td width="20">10</td>
  34. <td width="20">11</td>
  35. <td width="20">12</td>
  36. <td width="20">13</td>
  37. <td width="20">14</td>
  38. <td width="20">15</td>
  39. <td width="20">16</td>
  40. <td width="20">17</td>
  41. <td width="20">18</td>
  42. </tr>
  43. <tr>
  44. <td width="20">
  45. <img src="images/skill-1-mini.jpg" width="20" height="20" /><br>
  46. <img src="images/skill-2-mini.jpg" width="20" height="20" /><br>
  47. <img src="images/skill-3-mini.jpg" width="20" height="20" /><br>
  48. <img src="images/skill-4-mini.jpg" width="20" height="20" /><br>
  49. </td>
  50. <td width="20">
  51. <div class="column">
  52. <input type=radio name="1lvl" value="1"/><br>
  53. <input type=radio name="1lvl" value="2"/><br>
  54. <input type=radio name="1lvl" value="3"/><br>
  55. <input type=radio name="1lvl" value="4"/>
  56. </div>
  57. </td>
  58. <td width="20">
  59. <div class="column">
  60. <input type=radio name=2lvl value="1"/><br>
  61. <input type=radio name=2lvl value="2"/><br>
  62. <input type=radio name=2lvl value="3"/><br>
  63. <input type=radio name=2lvl value="4"/>
  64. </div>
  65. </td>
  66. <td width="20">
  67. <div class="column">
  68. <input type=radio name=3lvl value="1"/><br>
  69. <input type=radio name=3lvl value="2"/><br>
  70. <input type=radio name=3lvl value="3"/><br>
  71. <input type=radio name=3lvl value="4"/>
  72. </div>
  73. </td>
  74. <td width="20">
  75. <div class="column">
  76. <input type=radio name=4lvl value="1"/><br>
  77. <input type=radio name=4lvl value="2"/><br>
  78. <input type=radio name=4lvl value="3"/><br>
  79. <input type=radio name=4lvl value="4"/>
  80. </div>
  81. </td>
  82. <td width="20">
  83. <div class="column">
  84. <input type=radio name=5lvl value="1"/><br>
  85. <input type=radio name=5lvl value="2"/><br>
  86. <input type=radio name=5lvl value="3"/><br>
  87. <input type=radio name=5lvl value="4"/>
  88. </div>
  89. </td>
  90. <td width="20">
  91. <div class="column">
  92. <input type=radio name=6lvl value="1"/><br>
  93. <input type=radio name=6lvl value="2"/><br>
  94. <input type=radio name=6lvl value="3"/><br>
  95. <input type=radio name=6lvl value="4"/>
  96. </div>
  97. </td>
  98. <td width="20">
  99. <div class="column">
  100. <input type=radio name=7lvl value="1"/><br>
  101. <input type=radio name=7lvl value="2"/><br>
  102. <input type=radio name=7lvl value="3"/><br>
  103. <input type=radio name=7lvl value="4"/>
  104. </div>
  105. </td>
  106. <td width="20">
  107. <div class="column">
  108. <input type=radio name=8lvl value="1"/><br>
  109. <input type=radio name=8lvl value="2"/><br>
  110. <input type=radio name=8lvl value="3"/><br>
  111. <input type=radio name=8lvl value="4"/>
  112. </div>
  113. </td>
  114. <td width="20">
  115. <div class="column">
  116. <input type=radio name=9lvl value="1"/><br>
  117. <input type=radio name=9lvl value="2"/><br>
  118. <input type=radio name=9lvl value="3"/><br>
  119. <input type=radio name=9lvl value="4"/>
  120. </div>
  121. </td>
  122. <td width="20">
  123. <div class="column">
  124. <input type=radio name=10lvl value="1"/><br>
  125. <input type=radio name=10lvl value="2"/><br>
  126. <input type=radio name=10lvl value="3"/><br>
  127. <input type=radio name=10lvl value="4"/>
  128. </div>
  129. </td>
  130. <td width="20">
  131. <div class="column">
  132. <input type=radio name=11lvl value="1"/><br>
  133. <input type=radio name=11lvl value="2"/><br>
  134. <input type=radio name=11lvl value="3"/><br>
  135. <input type=radio name=11lvl value="4"/>
  136. </div>
  137. </td>
  138. <td width="20">
  139. <div class="column">
  140. <input type=radio name=12lvl value="1"/><br>
  141. <input type=radio name=12lvl value="2"/><br>
  142. <input type=radio name=12lvl value="3"/><br>
  143. <input type=radio name=12lvl value="4"/>
  144. </div>
  145. </td width="20">
  146. <td>
  147. <div class="column">
  148. <input type=radio name=13lvl value="1"/><br>
  149. <input type=radio name=13lvl value="2"/><br>
  150. <input type=radio name=13lvl value="3"/><br>
  151. <input type=radio name=13lvl value="4"/>
  152. </div>
  153. </td>
  154. <td width="20">
  155. <div class="column">
  156. <input type=radio name=14lvl value="1"/><br>
  157. <input type=radio name=14lvl value="2"/><br>
  158. <input type=radio name=14lvl value="3"/><br>
  159. <input type=radio name=14lvl value="4"/>
  160. </div>
  161. </td>
  162. <td width="20">
  163. <div class="column">
  164. <input type=radio name=15lvl value="1"/><br>
  165. <input type=radio name=15lvl value="2"/><br>
  166. <input type=radio name=15lvl value="3"/><br>
  167. <input type=radio name=15lvl value="4"/>
  168. </div>
  169. </td>
  170. <td width="20">
  171. <div class="column">
  172. <input type=radio name=16lvl value="1"/><br>
  173. <input type=radio name=16lvl value="2"/><br>
  174. <input type=radio name=16lvl value="3"/><br>
  175. <input type=radio name=16lvl value="4"/>
  176. </div>
  177. </td>
  178. <td width="20">
  179. <div class="column">
  180. <input type=radio name=17lvl value="1"/><br>
  181. <input type=radio name=17lvl value="2"/><br>
  182. <input type=radio name=17lvl value="3"/><br>
  183. <input type=radio name=17lvl value="4"/>
  184. </div>
  185. </td>
  186. <td width="20">
  187. <div class="column">
  188. <input type=radio name=18lvl value="1"/><br>
  189. <input type=radio name=18lvl value="2"/><br>
  190. <input type=radio name=18lvl value="3"/><br>
  191. <input type=radio name=18lvl value="4"/>
  192. </div>
  193. </td>
  194. </tr>
  195. </table>
  196. </div>
  197. <h3><a href="#">Additional Tips</a></h3>
  198. <div height="600">
  199. <textarea style="font-size: small;" name="txt" rows="10" cols="100">
  200. Write there additional hints. You can use html for <b>bold</b>, <i>italic</i> or <u>underlined</u> text
  201. </textarea>
  202. </div>
  203. </div>
  204. <div>
  205. <input type=submit value="Submit"/>
  206. </div>
  207. </form>
  208. </center></body>
  209. </html>

I chciałbym, żeby mi się te głupie radio boxy i text area pojawiły w bazie sciana.gif

Kiedy wysyłałem POSTy do show.php, który był napchany ifami i odzwierciedlał układ zaznaczonych radio buttonów wszystko trybiło.
Jakbt to coś dało to mój plik db.php, wygląda tak:
  1. <?php
  2. function connection() {
  3. // host
  4. $mysql_host = "localhost";
  5. // user
  6. $mysql_user = "POPRAWNY LOGIN";
  7. // hasło
  8. $mysql_pass = "POPRAWNE HASŁO";
  9. // nazwa bazy
  10. $mysql_db = "POPRAWNA NAZWA BAZY";
  11. // nawiązujemy połączenie z serwerem MySQL
  12. @mysql_connect($mysql_host, $mysql_user, $mysql_pass)
  13. or die('Brak połączenia z serwerem MySQL.');
  14. // łączymy się z bazą danych
  15. @mysql_select_db($mysql_db)
  16. or die('Błąd wyboru bazy danych.');
  17. }
  18.  
  19. ?>
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 17:26:32
Post #2





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


  1.  
  2. $do = "mysql_query('$insert')";


daj tak
  1.  
  2. $do = mysql_query($insert);
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 17:38:32
Post #3





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Rzeczywiście, był taki błąd :/ Te cholerne literówki, no ale i tak nie działa sciana.gif
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 17:41:22
Post #4





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


a co teraz dalej nie dodaje do bazy ?
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 17:49:24
Post #5





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Po prostu pusto, baza taka jaką ją zostawiłem po stworzeniu tabeli

Ten post edytował $_GET['Kuba'] 20.02.2011, 17:53:18
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 17:53:13
Post #6





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


jak ID masz autoincrement to nie przypisuj mu wartości
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 18:07:21
Post #7





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Nie działa, poprawiłem ID.

  1. <?php
  2. /*******************************************
  3. * Name: generate.php
  4. *******************************************/
  5.  
  6. require("includes/db.php");
  7. connection();
  8. $_1lvl = $_POST['1lvl'];
  9. $_2lvl = $_POST['2lvl'];
  10. $_3lvl = $_POST['3lvl'];
  11. $_4lvl = $_POST['4lvl'];
  12. $_5lvl = $_POST['5lvl'];
  13. $_6lvl = $_POST['6lvl'];
  14. $_7lvl = $_POST['7lvl'];
  15. $_8lvl = $_POST['8lvl'];
  16. $_9lvl = $_POST['9lvl'];
  17. $_10lvl = $_POST['10lvl'];
  18. $_11lvl = $_POST['11lvl'];
  19. $_12lvl = $_POST['12lvl'];
  20. $_13lvl = $_POST['13lvl'];
  21. $_14lvl = $_POST['14lvl'];
  22. $_15lvl = $_POST['15lvl'];
  23. $_16lvl = $_POST['16lvl'];
  24. $_17lvl = $_POST['17lvl'];
  25. $_18lvl = $_POST['18lvl'];
  26. $_txt = $_POST['txt'];
  27.  
  28. $insert = "INSERT INTO admiral (1lvl, 2lvl, 3lvl, 4lvl, 5lvl ,6lvl, 7lvl, 8lvl, 9lvl, 10lvl ,11lvl, 12lvl, 13lvl, 14lvlv, 15lvl, 16lvl, 17lvl, 18lvl, txt) VALUES('$_1lvl','$_2lvl','$_3lvl','$_4lvl','$_5lvl','$_6lvl','$_7lvl','$_8lvl','$_9lvl','$_10lvl','$_11lvl','$_12lvl','$_13lvl','$_14lvl','$_15lvl','$_16lvl','$_17lvl','$_18lvl','$_txt')";
  29. $do = mysql_query($insert);
  30. ?>


Screen z bazy
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 18:10:25
Post #8





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


a zwraca jakiś błąd?
usuń te małpy w pliku db.php
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 18:14:26
Post #9





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Małpy skasowane ale dalej nic. No właśnie nie wywala, żednego błędu. Strona cała biała dry.gif
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 18:25:18
Post #10





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


a zrób
  1. echo $_1lvl;
  2.  

i tak kilku innych


name="18lvl"

he he nie powstawiałeś w formularzu w cudzysłów pozmieniaj dopiero zauważyłem
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 18:35:56
Post #11





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


EDIT: Aha nie zauwazylem edita, spróbuje, chociaż to nic chyba nie zmieni, bo sie dane pojawiaja dobre: nextgenpocket.pl/dota

Ten post edytował $_GET['Kuba'] 20.02.2011, 18:38:48
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 18:37:09
Post #12





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


i do bazy też dodaje ?
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 18:42:09
Post #13





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Właśnie o to chodzi, że formularz był chyba w porządku, bo po poprawie nie dodaje dry.gif

Ten post edytował $_GET['Kuba'] 20.02.2011, 18:44:25
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 18:50:23
Post #14





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


a dobrą tabele wybrałeśquestionmark.gif
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 18:51:58
Post #15





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Tak mam tylko jedną tabele o nazwie admiral, kilka postow wczesniej dalem screena, moze to cos w bazie?

Ten post edytował $_GET['Kuba'] 20.02.2011, 18:53:19
Go to the top of the page
+Quote Post
Valdi_B
post 20.02.2011, 19:59:44
Post #16





Grupa: Zarejestrowani
Postów: 107
Pomógł: 30
Dołączył: 19.02.2011
Skąd: Warszawa

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


Twój skrypt kończy się instrukcją:
$do = mysql_query($insert);
bez żadnego sprawdzenia wyniku, więc nie wiadomo "jak poszło".

Co można sprawdzić:
- jaki wynik - $do,
- mysql_affected_rows(),
- mysql_error().

To powinno dać jakąś wskazówkę, co się dzieje.
Go to the top of the page
+Quote Post
kadlub
post 20.02.2011, 20:05:59
Post #17





Grupa: Zarejestrowani
Postów: 548
Pomógł: 105
Dołączył: 4.06.2010

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


nieźle tu namieszałeś ale chyba doszedłem dlaczego ci nie dodaje masz literówkę
  1.  
  2. $insert = "INSERT INTO admiral ( 1lvl, 2lvl, 3lvl, 4lvl, 5lvl ,6lvl, 7lvl, 8lvl, 9lvl, 10lvl ,11lvl, 12lvl, 13lvl, 14lvlv, 15lvl, 16lvl, 17lvl, 18lvl, txt) VALUES('$_1lvl','$_2lvl','$_3lvl','$_4lvl','$_5lvl','$_6lvl','$_7lvl','$_8lvl','$_9lvl','$_10lvl','$_11lvl','$_12lvl','$_13lvl','$_14lvl','$_15lvl','$_16lvl','$_17lvl','$_18lvl','$_txt')";
  3.  
  4.  


14lvl powinno być tak zmień i zobacz

Ten post edytował kadlub 20.02.2011, 20:13:54
Go to the top of the page
+Quote Post
$_GET['Kuba']
post 20.02.2011, 20:18:14
Post #18





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 19.02.2011

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


Cytat(Valdi_B @ 20.02.2011, 19:59:44 ) *
Twój skrypt kończy się instrukcją:
$do = mysql_query($insert);
bez żadnego sprawdzenia wyniku, więc nie wiadomo "jak poszło".

Co można sprawdzić:
- jaki wynik - $do,
- mysql_affected_rows(),
- mysql_error().

To powinno dać jakąś wskazówkę, co się dzieje.

Dzięki, dopisałem takie coś:
  1. if (!$do) {
  2. die('Złe zapytanie: ' . mysql_error());
  3. }

i otrzymałem "Złe zapytanie: Unknown column '14lvlv' in 'field list'"
Po poprawie działa, dzięki rządzicie thumbsupsmileyanim.gif
I pomyśleć, że jedna litera tyle zepsuła

Ten post edytował $_GET['Kuba'] 20.02.2011, 20:19:50
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: 16.04.2024 - 14:23