Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Newsy, Mam problem...
tommy4
post
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. ?>

(IMG:http://forum.php.pl/uwaga.gif)
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
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
O ja nie mogę, ale ze mnie debil!
Tu nie obrażamy innych użytkowników, w szczególności samych siebie. Z racji ze jestes tu nowy masz na razie tylko ustną naganę (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

swoją drogą to dziwne ze ci przyjął zapytanie bez podania tematu. Najwyraźniej nie dokladnie nam pokazales sql pol tabeli

co do id to nie musisz podawac. poto wlasnie jest autoicrement (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
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: 6.10.2025 - 03:05