Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Newsy, Mam problem...
tommy4
post 2.12.2005, 13:02:21
Post #1





Grupa: Zarejestrowani
Postów: 288
Pomógł: 12
Dołączył: 2.12.2005

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


Wyobraźcie sobie tabelę:

id smallint(5) unsigned not null auto_increment
temat varchar(200) not null
autor smallint(5) unsigned not null default '1'
miesiac smallint(5) unsigned not null default '0'
tresc text not null
data int(10) unsigned not null default '0'

I mam taki problem: chcę dodać do bazy danych tylko i wyłącznie treść newsa i używam w tym celu takiego kodu:

  1. <?php
  2. require_once "../main.php";
  3. ?>
  4. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  5. <label>Treść:<br>
  6. <textarea name="tresc" rows="10" cols="40">
  7. </textarea></label><br>
  8. <input type="submit" value="Zapisz">
  9. </form>
  10.  
  11. <?php
  12. if (isset($_POST['tresc'])) {
  13. $trescnewsa = $_POST['tresc'];
  14. $sql = "INSERT INTO newsy (tresc) VALUES ('$trescnewsa')";
  15. if(@mysql_query($sql)) {
  16. echo '<p>Twój news został dodany.</p>';
  17. }
  18. else {
  19. echo '<p>Błąd podczas dodawania newsa: ' . mysql_error() . '</p>';
  20. }
  21. }
  22. ?>


poprawiam
---
nospor



Mam problem, nie chce się tabela dodawać. Wyświetla Bład podczas dodawania newsa. Co mam źle?
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: 24.07.2025 - 17:15