Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Błąd w html podczas wywoływania errora, Mały błędzik :)
kiepski96
post
Post #1





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

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


Witam,otóż mam problem :

Mam kod,dzięki któremu po przekroczeniu określonej liczby rejestracji ( w poniższym przypadku jest 2 ) wyświetla się tekst "Brak nagrody "

Lecz tak nie jest,nie wyświetla się .
Dane do mysql są ok.

Myślę,że coś pochrzaniłem z html.
Czy mógłbym prosić o kod html, który będzie właśnie wyświetlał ten error ?

Oto mój php :

  1. <?php
  2. if (!isset($_SESSION['username']))
  3. {
  4. header('Location: ./login.php');
  5. }
  6. ?>
  7. <?php
  8. $error_message = "";
  9. $action = isset($_POST['action']) ? $_POST['action'] : '';
  10. $mysql_server = 'localhost';
  11. $mysql_username = 'xxx';
  12. $mysql_password = 'xxx';
  13. $mysql_database = 'xxx';
  14. $mysql_table = 'nagroda1';
  15. $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
  16. mysql_select_db($mysql_database, $db);
  17. $sql = "SELECT id FROM ".$mysql_table;
  18. $result = mysql_query($sql, $db);
  19. $nagroda1=mysql_num_rows($result);
  20.  
  21. if ($_SERVER['REQUEST_METHOD'] == 'POST' && $nagroda1 >= 2 )
  22. {
  23.  
  24. $error_message = "Pula nagród wyczerpana.";
  25. }
  26. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kiepski96
post
Post #2





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

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


Proszę ,cały kod :

  1. <?php
  2. if (!isset($_SESSION['username']))
  3. {
  4. header('Location: ./login.php');
  5. }
  6. ?>
  7.  
  8. <?php
  9. $error_message1 = "";
  10. $action = isset($_POST['action']) ? $_POST['action'] : '';
  11. $mysql_server = 'localhost';
  12. $mysql_username = 'xxx';
  13. $mysql_password = 'xxx';
  14. $mysql_database = 'xxx';
  15. $mysql_table1 = 'nagroda1';
  16. $mysql_table2 = 'nagroda2';
  17. $mysql_table3 = 'nagroda3';
  18. $mysql_table4 = 'nagroda4';
  19. $mysql_table5 = 'nagroda5';
  20. $mysql_table6 = 'nagroda6';
  21. // Tabele do errorów
  22. $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
  23. mysql_select_db($mysql_database, $db);
  24. $sql1 = "SELECT id FROM ".$mysql_table1;
  25. $sql2 = "SELECT id FROM ".$mysql_table2;
  26. $sql3 = "SELECT id FROM ".$mysql_table3;
  27. $sql4 = "SELECT id FROM ".$mysql_table4;
  28. $sql5 = "SELECT id FROM ".$mysql_table5;
  29. $sql6 = "SELECT id FROM ".$mysql_table6;
  30. $result1 = mysql_query($sql1, $db);
  31. $result2 = mysql_query($sql2, $db);
  32. $result3 = mysql_query($sql3, $db);
  33. $result4 = mysql_query($sql4, $db);
  34. $result5 = mysql_query($sql5, $db);
  35. $result6 = mysql_query($sql6, $db);
  36.  
  37. $mysql_table1=mysql_num_rows($result1);
  38.  
  39. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $mysql_table1 >= 2 ) // Ilość nagrody 1
  40. {
  41. $error_message1 = 'Brak nagrody';
  42. }
  43. else
  44. // Brak nagrody 1
  45. $mysql_table2=mysql_num_rows($result2);
  46.  
  47. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $mysql_table2 >= 2 ) // Ilość nagrody 2
  48. {
  49. $error_message2 = 'Brak nagrody2';
  50. }
  51. else
  52. // Brak nagrody 2
  53. $nagroda3=mysql_num_rows($result3);
  54.  
  55. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $nagroda3 >= 2 ) // Ilość nagrody 3
  56. {
  57. $error_message3 = 'Brak nagrody';
  58. }
  59. else
  60. // Brak nagrody 3
  61.  
  62. $nagroda4=mysql_num_rows($result4);
  63.  
  64. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $nagroda4 >= 2 ) // Ilość nagrody 4
  65. {
  66. $error_message4 = 'Brak nagrody';
  67. }
  68. else
  69. // Brak nagrody 4
  70.  
  71. $nagroda5=mysql_num_rows($result5);
  72.  
  73. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $nagroda5 >= 2 ) // Ilość nagrody 5
  74. {
  75. $error_message5 = 'Brak nagrody';
  76. }
  77. else
  78. // Brak nagrody 5
  79.  
  80. $nagroda6=mysql_num_rows($result6);
  81.  
  82. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $nagroda6 >= 2 ) // Ilość nagrody 6
  83. {
  84. $error_message6 = 'Brak nagrody';
  85. }
  86. else
  87. // Brak nagrody 6
  88.  
  89. ?>
  90. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  91. <html>
  92. <head>
  93. <meta http-equiv="Content-Language" content="pl">
  94. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  95. <title>Katalog nagród</title>
  96. <style type="text/css">
  97. div#container
  98. {
  99. width: 1250px;
  100. position: relative;
  101. margin-top: 0px;
  102. margin-left: auto;
  103. margin-right: auto;
  104. text-align: left;
  105. }
  106. </style>
  107. <style type="text/css">
  108. body
  109. {
  110. text-align: center;
  111. margin: 0;
  112. background-color: #FFFFFF;
  113. color: #000000;
  114. }
  115. </style>
  116. <script type="text/javascript">
  117. <!--
  118. function SetImage(id, filename)
  119. {
  120. var elem=document.getElementById(id);
  121. if(elem)
  122. {
  123. elem.src=filename;
  124. }
  125. }
  126. //-->
  127. </script>
  128. </head>
  129. <body>
  130. <div id="container">
  131. <div id="wb_Shape1" style="margin:0;padding:0;position:absolute;left:259px;top:295px;width:745px;heigh
    t:884px;text-align:left;z-index:0;">
  132. <img src="images/img0015.png" id="Shape1" alt="" title="" style="border-width:0;width:745px;height:884px"></div>
  133. <div id="wb_Image1" style="margin:0;padding:0;position:absolute;left:254px;top:46px;width:740px;height
    :168px;text-align:left;z-index:1;">
  134. <img src="images/top.bez.png" id="Image1" alt="" border="0" style="width:740px;height:168px;"></div>
  135. <div id="wb_Image2" style="margin:0;padding:0;position:absolute;left:253px;top:0px;width:105px;height:
    45px;text-align:left;z-index:2;">
  136. <a href="./index.html" onmouseover="SetImage('Image2','images/button-niebieski_01.png');return false;" onmouseout="SetImage('Image2','images/przycisk-szary1_01.png');return false;"><img src="images/przycisk-szary1_01.png" id="Image2" alt="" border="0" style="width:105px;height:45px;"></a></div>
  137. <div id="wb_Image3" style="margin:0;padding:0;position:absolute;left:358px;top:0px;width:105px;height:
    45px;text-align:left;z-index:3;">
  138. <a href="./rejestracja.html" onmouseover="SetImage('Image3','images/button-niebieski_02.png');return false;" onmouseout="SetImage('Image3','images/przycisk-szary1_02.png');return false;"><img src="images/przycisk-szary1_02.png" id="Image3" alt="" border="0" style="width:105px;height:45px;"></a></div>
  139. <div id="wb_Image4" style="margin:0;padding:0;position:absolute;left:463px;top:0px;width:105px;height:
    45px;text-align:left;z-index:4;">
  140. <a href="./oferty.html" onmouseover="SetImage('Image4','images/button-niebieski_03.png');return false;" onmouseout="SetImage('Image4','images/przycisk-szary1_03.png');return false;"><img src="images/przycisk-szary1_03.png" id="Image4" alt="" border="0" style="width:105px;height:45px;"></a></div>
  141. <div id="wb_Image5" style="margin:0;padding:0;position:absolute;left:568px;top:0px;width:105px;height:
    45px;text-align:left;z-index:5;">
  142. <a href="./dowody.html" onmouseover="SetImage('Image5','images/button-niebieski_04.png');return false;" onmouseout="SetImage('Image5','images/przycisk-szary1_04.png');return false;"><img src="images/przycisk-szary1_04.png" id="Image5" alt="" border="0" style="width:105px;height:45px;"></a></div>
  143. <div id="wb_Image6" style="margin:0;padding:0;position:absolute;left:673px;top:0px;width:105px;height:
    45px;text-align:left;z-index:6;">
  144. <a href="./zasady.html" onmouseover="SetImage('Image6','images/button-niebieski_05.png');return false;" onmouseout="SetImage('Image6','images/przycisk-szary1_05.png');return false;"><img src="images/przycisk-szary1_05.png" id="Image6" alt="" border="0" style="width:105px;height:45px;"></a></div>
  145. <div id="wb_Image7" style="margin:0;padding:0;position:absolute;left:778px;top:0px;width:105px;height:
    45px;text-align:left;z-index:7;">
  146. <a href="./wyplata.html" onmouseover="SetImage('Image7','images/button-niebieski_06.png');return false;" onmouseout="SetImage('Image7','images/przycisk-szary1_06.png');return false;"><img src="images/przycisk-szary1_06.png" id="Image7" alt="" border="0" style="width:105px;height:45px;"></a></div>
  147. <div id="wb_Image8" style="margin:0;padding:0;position:absolute;left:883px;top:0px;width:105px;height:
    45px;text-align:left;z-index:8;">
  148. <a href="./forum.html" onmouseover="SetImage('Image8','images/button-niebieski_07.png');return false;" onmouseout="SetImage('Image8','images/przycisk-szary1_07.png');return false;"><img src="images/przycisk-szary1_07.png" id="Image8" alt="" border="0" style="width:105px;height:45px;"></a></div>
  149. <div id="wb_Image9" style="margin:0;padding:0;position:absolute;left:354px;top:326px;width:154px;heigh
    t:240px;text-align:left;z-index:9;">
  150. <a href="./nagroda1.php"><img src="images/godzrestocku.png" id="Image9" alt="" border="0" style="width:154px;height:240px;"></a></div>
  151. <div id="wb_Image10" style="margin:0;padding:0;position:absolute;left:552px;top:326px;width:154px;heigh
    t:240px;text-align:left;z-index:10;">
  152. <img src="images/javelin30.png" id="Image10" alt="" border="0" style="width:154px;height:240px;"></div>
  153. <div id="wb_Image11" style="margin:0;padding:0;position:absolute;left:750px;top:326px;width:154px;heigh
    t:240px;text-align:left;z-index:11;">
  154. <img src="images/pktx2.png" id="Image11" alt="" border="0" style="width:154px;height:240px;"></div>
  155. <div id="wb_Image12" style="margin:0;padding:0;position:absolute;left:354px;top:602px;width:154px;heigh
    t:240px;text-align:left;z-index:12;">
  156. <img src="images/premiumnagrodaeu.png" id="Image12" alt="" border="0" style="width:154px;height:240px;"></div>
  157. <div id="wb_Image13" style="margin:0;padding:0;position:absolute;left:552px;top:602px;width:154px;heigh
    t:240px;text-align:left;z-index:13;">
  158. <img src="images/premka3.png" id="Image13" alt="" border="0" style="width:154px;height:240px;"></div>
  159. <div id="wb_Image14" style="margin:0;padding:0;position:absolute;left:751px;top:602px;width:154px;heigh
    t:240px;text-align:left;z-index:14;">
  160. <img src="images/losowygift.png" id="Image14" alt="" border="0" style="width:154px;height:240px;"></div>
  161. <div id="wb_Shape2" style="margin:0;padding:0;position:absolute;left:413px;top:234px;width:453px;heigh
    t:52px;text-align:center;z-index:15;">
  162. <img src="images/img0016.png" id="Shape2" alt="" title="" style="border-width:0;width:453px;height:52px"></div>
  163. <div id="Html1" style="position:absolute;left:593px;top:459px;width:222px;height:252px;z-index:16">
  164.  
  165. <div id="brak1" style="position:absolute;left:-200px;top:76px;width:119px;height:29px;z-index:16">
  166. <?php echo $error_message1;?></div>
  167.  
  168. <div id="brak2" style="position:absolute;left:40px;top:90px;width:130px;height:29px;z-index:16">
  169. <?php echo $error_message2;?></div>
  170.  
  171. <div id="brak3" style="position:absolute;left:-200px;top:76px;width:119px;height:29px;z-index:16">
  172. <?php echo $error_message3;?></div>
  173.  
  174. <div id="brak4" style="position:absolute;left:-200px;top:76px;width:119px;height:29px;z-index:16">
  175. <?php echo $error_message4;?></div>
  176.  
  177. <div id="brak5" style="position:absolute;left:-200px;top:76px;width:119px;height:29px;z-index:16">
  178. <?php echo $error_message5;?></div>
  179.  
  180. <div id="brak6" style="position:absolute;left:-200px;top:76px;width:119px;height:29px;z-index:16">
  181. <?php echo $error_message6;?></div>
  182. </div>
  183. </div>
  184. </body>
  185. </html>
Go to the top of the page
+Quote Post

Posty w temacie
- kiepski96   Błąd w html podczas wywoływania errora   2.04.2011, 20:03:38
- - kadlub   [PHP] pobierz, plaintext echo "Pula nagród wy...   2.04.2011, 20:09:22
- - kiepski96   Czy po bezpośrednim wklejeniu tego do tego skryptu...   2.04.2011, 20:17:42
- - mlawnik   Mysle ze tak, ale sproboj. Sorry za ort, zaraz zm...   2.04.2011, 20:29:53
- - kadlub   jak chcesz ten cały kod wstawić w div i coś tam j...   2.04.2011, 20:34:56
- - kiepski96   Nadal nic. Trochę musiałem zmienić . Teraz jest ph...   3.04.2011, 19:56:03
- - kadlub   próbujesz wyświetlić zmienną $error_message1 ...   4.04.2011, 07:29:49
- - kiepski96   Wszystko jest w jednym pliku spis.php, tylko daje ...   4.04.2011, 10:06:49
- - kadlub   [PHP] pobierz, plaintext if ($_SERVER['RE...   4.04.2011, 13:57:23
- - kiepski96   Już nie wiem co mam robić. Może dam cały kod : [P...   4.04.2011, 16:14:39
- - kadlub   [PHP] pobierz, plaintext if ($_SERVER['RE...   4.04.2011, 16:27:38
- - kiepski96   Działa, ale teraz chciałem wywołać wiele błędów i ...   4.04.2011, 17:38:20
- - kadlub   jak wszystkie zapytania ponazywałeś tak samo to ni...   4.04.2011, 17:48:51
- - kiepski96   Teraz mam kłopot,ponieważ nie chce wyświetlić wszy...   4.04.2011, 18:04:54
- - kadlub   pokaż jak teraz ten twój kod wygląda   4.04.2011, 18:08:15
- - kiepski96   Proszę ,cały kod : [PHP] pobierz, plaintext <?...   4.04.2011, 18:13:41
- - kadlub   poczytaj trochę na temat php bo tak będziemy pisać...   4.04.2011, 18:19:17
- - kiepski96   No na początku tak miałem bez else,ale potem mi co...   4.04.2011, 18:21:04


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: 15.10.2025 - 21:11