Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][sql]Problem z zapisem do bazy
Zimon
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 7.08.2006

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


mam mały problem z dodaniem do bazy danch nie wiem gdzie jest błąd w każdym bądź razie dane z formularza są przekazywane globalnie i przez funkcję zmieniającą wpis w bazie sa odczytane prawidłowo, nie chce nationas się wykonać wpis do bazy i nie wiem czemu

plik admin/option.adm.php
  1. <?php
  2. $katalog = 'theme';
  3. function option_form()
  4. {
  5. global $katalog, $title_, $key_word_, $describe_, $footer_, $theme_;
  6.  
  7. $dir = $katalog.'/';
  8. $d = dir( $dir );
  9. while (false !== ($entry = $d->read()))
  10. {
  11.  if( is_dir( $dir.$entry ) && $entry != '.' && $entry != '..' ) 
  12.  {
  13. $fileArray[] = $entry;
  14.  }
  15. }
  16. $d->close();
  17.  
  18. $query = "SELECT * FROM config WHERE cfg='1'";
  19. $result = mysql_query($query);
  20. $r = mysql_fetch_assoc($result);
  21. $title = $r['title'];
  22. $footer = $r['footer'];
  23. $describe = $r['describe'];
  24. $key_word = $r['key_word'];
  25. $theme = $r['theme'];
  26.  
  27. echo '
  28. <br>
  29. <fieldset>
  30. <form action="admin.php?mod=option&action=change" method="POST" name="zmiana">
  31. <legend>Pozostałe ustawienia</legend>
  32. <table width="100% align="center">
  33. <tr>
  34. <td width="45%" align="right" valign="top" size="30">Tytuł strony</td>
  35. <td width="55%" align="left"><input type="text" name="title_" value="'.$title.'"></td>
  36. </tr>
  37. <tr>
  38. <td width="45%" align="right" valign="top" size="30">Stopka strony</td>
  39. <td width="55%" align="left"><input type="text" name="footer_" value="'.$footer.'"></td>
  40. </tr>
  41. <tr>
  42. <td width="45%" align="right" valign="top">Słowa kluczowe</td>
  43. <td width="55%" align="left"><input type="text" size="30" name="key_word_" value="'.$key_word.'"></td>
  44. </tr>
  45. <tr>
  46. <td width="45%" align="right" valign="top">Opis</td>
  47. <td width="55%" align="left"><input type="text" size="30" name="describe_" value="'.$describe.'"></td>
  48. </tr>
  49. <tr>
  50. <td width="45%" align="right" valign="top">Skórka</td>
  51. <td width="55%" align="left">
  52. <SELECT name="theme_">';
  53.  foreach ($fileArray as $name)
  54.  { 
  55. if ($name == $theme) {$e = 'SELECTED';}
  56. '<OPTION VALUE="'.$name.'" '.$e.'>'.$name;
  57.  }
  58. echo  
  59.  '</SELECT></td>
  60. </tr>
  61. <tr>
  62. <td width="45%" align="right" valign="top"></td>
  63. <td width="55%" align="left"><input type="submit" value="zmień"></td>
  64. </tr>
  65. </table>
  66. </form>
  67. </fieldset>
  68.  
  69. ';
  70. }
  71.  
  72. function option_change()
  73. {
  74. global $title_, $key_word_, $describe_, $footer_, $theme_;
  75. if ($title_ == '' || $key_word_ == '' || $describe_ == '' || $footer_ == '' || $theme_ == '')
  76. {
  77. echo '<strong>Błąd: musisz wypełnic wszystkie pola</strong>';
  78. }
  79.  
  80. $query = "UPDATE config SET title='$title_', key_word='$key_word_', describe='$describe_', footer='$footer_', theme='$theme_' WHERE cfg='1'";
  81. $result = mysql_query($query) or die ('aaaaaaa'.mysql_error());
  82. /*header("Location: admin.php?mod=others");
  83. exit;*/
  84. }
  85. ?>


fragment pliku admin.php
  1. <?php
  2. if ($_GET['mod']=='option')
  3. {
  4.  include_once('admin/option.adm.php');
  5.  option_form();
  6.  if($_GET['action']=='change')
  7.  {
  8.  option_change();
  9.  }
  10. }
  11. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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: 22.08.2025 - 17:39