Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Edytowanie strony - formularz, Po poprawce: Gotowy skrypt do edycji bazy danych za pomocą formularza
thurinon
post 18.09.2010, 02:38:33
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 2
Dołączył: 8.10.2009

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


Witam,
oto kod

  1. <?php
  2. if(isset($_GET['edit']))
  3. {
  4. $id = $_GET['edit'];
  5.  
  6. $sql = "SELECT * FROM sites WHERE id = $id";
  7. $res = mysql_query($sql) or die('Zapytanie: '.$sql.' --- błąd: '.mysql_error());
  8.  
  9. while ($row = mysql_fetch_array($res))
  10. {
  11.  
  12. <form action="?akcja=edit_site&&editauto='.$id.'" method="POST">
  13. <table cellspacing="0" summary="">
  14. <tbody>
  15. <tr>
  16. <td>Nazwa strony</td><td><input name="title" value="'.$row['site'].'"/></td>
  17. </tr>
  18. <tr>
  19. <td>Treść</td><td><textarea name="concent">'.$row['concent'].'</textarea></td>
  20. </tr>
  21. <tr>
  22. <td>Tagi</td><td><input name="tagi" value="'.$row['tags'].'"/></td>
  23. </tr>
  24. <tr>
  25. <td colspan="2">Dodatkowe</td>
  26. </tr>
  27. <tr>
  28. <td>Tytuł strony</td><td><input name="meta_title" value="'.$row['meta_title'].'"/></td>
  29. </tr>
  30. <tr>
  31. <td>Opis strony</td><td><input name="meta_descriptions" value="'.$row['meta_descriptions'].'"/></td>
  32. </tr>
  33. <tr>
  34. <td>Słowa kluczowe</td><td><input name="meta_keywords" value="'.$row['meta_keywords'].'"/></td>
  35. </tr>
  36. <tr>
  37. <td colspan="2"><input type="submit" value="Aktualizuj" /></td>
  38. </tr>
  39. </tbody>
  40. </table>
  41. </form>
  42. ';
  43. }
  44. }
  45. elseif(isset($_GET['editauto']))
  46. {
  47. include('../functions/nopl.php');
  48.  
  49.  
  50. $title = $_POST['title'];
  51. $concent = $_POST['concent'];
  52. $tags = $_POST['tagi'];
  53. $meta_title = $_POST['meta_title'];
  54. $meta_descriptions = $_POST['meta_descriptions'];
  55. $meta_keywords = $_POST['meta_keywords'];
  56.  
  57. $editauto = $_GET['editauto'];
  58.  
  59. // dodajemy rekord do bazy
  60. $zapytanie = "UPDATE `sites` SET `site` = '$title', `concent` = '$concent', `tags` = '$tags', `meta_title` ='$meta_title', `meta_descriptions` = '$meta_descriptions', `meta_keywords` = '$meta_keywords' WHERE id = '$editauto'";
  61. $idzapytania = mysql_query($zapytanie)or die('Zapytanie: '.$sql.' --- błąd: '.mysql_error());
  62.  
  63. echo '<br />Strona Zoztała poprawnie zaktualizowana<br />';
  64.  
  65. echo 'Nazwa strony - '.$site.'<br />Tagi - '.$tags.'<br />Znaczniki meta:<br />Tytuł - '.$meta_title.'<br />Opis - '.$meta_descriptions.'<br />Słowa kluczowe - '.$meta_keywords.'<br />Treść:<br />'.$concent.'';
  66.  
  67. echo '<a href="?akcja=edit_site&&edit='.$editauto.'">Edytuj ponownie stronę '.$site.'</a><br /><a href="/">Panel administracyjny</a>';
  68. }
  69.  
  70.  
  71. else
  72. echo ' Kup linę, następnie się na niej powieś';
  73.  
  74. ?>


A w tym kodzie jest błąd.

Do formularza wczytują się odpowiednie dane, klikam przycisk aktualizuj, i wyskakuje błąd:
Zapytanie: SELECT * FROM sites --- błąd: Something is wrong in your syntax obok 'meta_title` ='1111111111111', `meta_descriptions` = '111111111111111', `meta_key' w linii 1

Please help me smile.gif
Dzięki z góry

Ten post edytował thurinon 18.09.2010, 04:57:11
Go to the top of the page
+Quote Post

Posty w temacie


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 - 13:23