Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][MYSQL] komunikat
Forum PHP.pl > Forum > Przedszkole
krzychu0808
Co oznacza ten komunikat:
Fatal error: Cannot redeclare html_header() (previously declared in C:\Program Files\Apache Group\Apache2\htdocs\2\register.php:14) in C:\Program Files\Apache Group\Apache2\htdocs\2\common_db.inc on line 41

oraz:
dal tej linijki
  1. <?php
  2. $country_array = enum_options('usercountry', $link_id);
  3. ?>

mam bład:
Fatal error: Call to undefined function enum_options() in C:\Program Files\Apache Group\Apache2\htdocs\2\register.php on line 27
Maxik
Próbujesz ustawić nagłówek który został już ustawiony(chyba), drugi to odwołanie do nieistniejącej funkcji.
krzychu0808
kurde pomóżcie bo napisałem skrypt rejestracji ale mam błąd:
Notice: Undefined variable: action in C:\Program Files\Apache Group\Apache2\htdocs\2\register2.php on line 175
linijka 175 odpowiada tej linijce co jest w kodzie niżej... proszę pomóżcie
kod:
  1. <?php
  2. $default_dbname = 'sample_db';
  3. $user_tablename = 'user';
  4. $MYSQL_ERRNO = '';
  5. $MYSQL_ERROR = '';
  6.  
  7. function sql_error() {
  8. global $MYSQL_ERRNO, $MYSQL_ERROR;
  9.  
  10. if(empty($MYSQL_ERROR)) {
  11. $MYSQL_ERRNO = mysql_errno();
  12. $MYSQL_ERROR = mysql_error();
  13. }
  14. return "$$MYSQL_ERRNO: $MYSQL_ERROR";
  15. }
  16. $link_id = mysql_connect("localhost","root","xx");
  17. mysql_select_db('sample_db', $link_id);
  18. mysql_close($link_id);
  19.  
  20. function html_header() {
  21. ?>
  22. <HTML>
  23. <HEAD><title>Rejestracja</title></HEAD>
  24. <body>
  25. <?php
  26. }
  27.  
  28. function html_footer() {
  29. ?>
  30. </body>
  31. </HTML>
  32. <?php
  33. }
  34.  
  35. function in_use($userid) {
  36. global $usertable_name;
  37.  
  38. $query = "SELECT userid FROM $usertable_name WHERE userid = '$userid'";
  39. $result = mysql_query($query, $link_id);
  40. if(!mysql_num_rows($result)) return 0;
  41. else return 1;
  42. }
  43.  
  44. function register_form() {
  45. global $userid, $username, $usercountry, $useremail, $userprofile, $country_array;
  46. global $PHP_SELF;
  47.  
  48. ?>
  49. <center>Rejestracja</center>
  50. <form method="POST" action="<?php echo $PHP_SELF ?>">
  51. <input type="hidden" name="action" value="register">
  52. <div align="center"><center><table border="1" width="90%">
  53. <tr>
  54. <th width="30%" nowrap>Login</th>
  55. <td width="70%"><input type="TEXT" name="userid" value="<?php echo $userid ?>" size="8" maxlength="20"></td>
  56. </tr>
  57.  
  58. <tr>
  59. <th width="30%" nowrap>Hasło</th>
  60. <td width="70%"><input type="password" name="userpassword" size="15"></td>
  61. </tr>
  62.  
  63. <tr>
  64. <th width="30%" nowrap>Powtórz Hasło</th>
  65. <td width="70%"><input type="password" name="userpassword2" size="15"></td>
  66. </tr>
  67.  
  68. <tr>
  69. <th width="30%" nowrap>Imię i Nazwisko</th>
  70. <td width="70%"><input type="TEXT" name="username" value="<?php echo $username ?>" size="20"></td>
  71. </tr>
  72.  
  73. <tr>
  74. <th width="30%" nowrap>Kraj</th>
  75. <td width="70%"><input type="TEXT" name="username" value="<?php echo $usercountry ?>" size="20"></td>
  76. </tr>
  77.  
  78. <tr>
  79. <th width="30%" nowrap>Email</th>
  80. <td width="70%"><input type="TEXT" name="useremail" size="20" value="<?php echo $useremail ?>" ></td>
  81. </tr>
  82.  
  83. <tr>
  84. <th width="30%" nowrap>Opis Użytkownika</th>
  85. <td width="70%"><textarea rows="5" cols="40" name="userprofile"></textarea></td>
  86. </tr>
  87.  
  88. <tr>
  89. <th width="30%" colspan="2" nowrap>
  90. <input type="submit" value="Rejestruj">
  91. <input type="reset" value="Wyczyść">
  92. </th>
  93. </tr>
  94. </table>
  95. </center>
  96. </div>
  97. </form>
  98. <?php
  99. }
  100. function create_account() {
  101. global $userid, $username, $userpassword, $userpassword2, $usercountry, $useremail, $userprofile;
  102. global $default_dbname, $user_tablename;
  103.  
  104. if(empty($userid)) error_message("Podaj Login!");
  105. if(empty($userpassword)) error_message("Podaj Hasło!");
  106. if(strlen($userpassword) < 4 ) error_message("Hasło jest zbyt krótkie!");
  107. if(empty($userpassword2)) error_message("Powtórnie podaj Hasło!");
  108. if(empty($username)) error_message("Podaj imię i nazwisko!");
  109. if(empty($useremail)) error_message("Podaj adres email!");
  110. if(empty($usercountry)) error_message("Podaj Kraj!");
  111. if(empty($userprofile)) $userprofile = "Brak opisu";
  112. if($userpassword != $userpassword2) error_message("Wybrane i powtórzone hasła nie są identyczne!");
  113.  
  114. $link_id = mysql_connect('localhost','root','xx');
  115. mysql_select_db('sample_db', $link_id);
  116.  
  117. if(in_use($userid)) error_message("Nazwa Użytkownika $userid jest już zajęta. Wybierz inny login.");
  118.  
  119. $query = "INSERT INTO user VALUES(NULL, '$userid', password('$userpassword'), '$username', 'M', 'Brak Daty Urodzin', 'Brak Adresu', '$usercountry', '$useremail', '$userprofile', 'Brak danych o zaintereswoaniach', 'Brak danych o pseudonimie', 'Brak NR GG', 'curdate(), NULL)";
  120.  
  121. $result = mysql_query($query, $link_id);
  122. if(!$result) error_message(sql_error());
  123. $usernumber = mysql_insert_id($link_id);
  124. html_header();
  125. ?>
  126. <CENTER><?php echo $username ?>, dziękujemy za zarejestrowanie się!</CENTER>
  127. <div align="center"><center><table border="1" width="90%">
  128. <tr>
  129.  <th width="30%" nowrap>Numer użytkownik</th>
  130.  <td width="70"><?php echo $usernumber ?></td>
  131. </tr>
  132.  
  133. <tr>
  134.  <th width="30%" nowrap>Wybrany identyfikator</th>
  135.  <td width="70"><?php echo $userid ?></td>
  136. </tr>
  137.  
  138. <tr>
  139.  <th width="30%" nowrap>Wybrane hasło</th>
  140.  <td width="70"><?php echo $userpassword ?></td>
  141. </tr>
  142.  
  143. <tr>
  144.  <th width="30%" nowrap>Imię i Nazwisko</th>
  145.  <td width="70"><?php echo $username ?></td>
  146. </tr>
  147.  
  148. <tr>
  149.  <th width="30%" nowrap>Kraj</th>
  150.  <td width="70"><?php echo $usercountry ?></td>
  151. </tr>
  152.  
  153. <tr>
  154.  <th width="30%" nowrap>Kraj</th>
  155.  <td width="70"><?php echo $usercountry ?></td>
  156. </tr>
  157.  
  158. <tr>
  159.  <th width="30%" nowrap>Email</th>
  160.  <td width="70"><?php echo $useremail ?></td>
  161. </tr>
  162.  
  163. <tr>
  164.  <th width="30%" nowrap>Opis</th>
  165.  <td width="70"><?php echo htmlspecialchars($userprofile) ?></td>
  166. </tr>
  167. </table>
  168. </center>
  169. </div>
  170. <?php
  171. html_footer();
  172. }
  173.  
  174. switch($action) {
  175. case "register":
  176. create_account();
  177. break;
  178. default:
  179. html_header();
  180. register_form();
  181. html_footer();
  182. break;
  183. }
  184. ?>
Maxik
Nie masz ustawionej zmiennej $action.
krzychu0808
i to jest formularz rejestracji z książki helion php 4 od podstaw(2000r) trochę zmodyfikowane łączenie z bazą danych ale to działa
nospor
ech.. register_globals
http://nospor.pl/php-faq-n29.html#faq-3
krzychu0808
o co ci chodzi nospor tongue.gif
Maxik
Np. global $PHP_SELF; powinno być $_SERVER['php_self']; winksmiley.jpg
krzychu0808
a to coś da jeżeli jest wyłączona ta fukcja questionmark.gifquestionmark.gif
nospor
Cytat
o co ci chodzi nospor
to ja tak pisze za mądrze czy po prostu tobie nie chcialo sie tego przetrawic? winksmiley.jpg

czyli u ciebie w kodzie ma byc : $_POST['action'] zamiast $action.
A na przyszlosc sprobuj przetrawic informacje jakie dostajesz
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.