![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 47 Pomógł: 0 Dołączył: 20.11.2010 Ostrzeżenie: (0%) ![]() ![]() |
Próbowałem napisać prosty formularz, ale nic z tego nie wyszło... Pojawia się Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /x/public_html/newthread.php on line 30.
Kod <?php ob_start(); require 'includes/config.php'; session_start(); $number = $_GET['id']; $user = $_SESSION['user_id']; if(empty($_GET)) { echo "nie wybrano nic"; } else {?> <form method="post">Tytuł wątku: <input type="text" name="name" size="50" /><br> Opis wątku: <input type="text" name="desc" size="50" /><br> Treść: <br><textarea name="text" cols="15" rows="30"></textarea><br> <input type="submit" value="Wyslij!" /> <?php } $name=$_POST["name"]; $desc=$_POST["desc"]; $text=$_POST["text"]; $user=$_POST["user"]; $zapis = "INSERT INTO threads (id, pid, name, desc, author, text, date) VALUES ('', 'x', '$name', '$desc', '$text', '$user', '')"; $wyn = mysql_query($zapis); $dane = mysql_fetch_array($wyn); echo "x ".$_POST["name"]." został wysłany."; ob_end_flush(); ?> Czy ktoś mógłby powiedzieć co zrobiłem źle? Ten post edytował IceBeast 16.02.2011, 20:00:23 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 47 Pomógł: 0 Dołączył: 20.11.2010 Ostrzeżenie: (0%) ![]() ![]() |
Teraz
Kod Array ( ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''descc', author, text, date) VALUES ('', 'x', '', '', '', '', '')' at line 1 :/ Teraz w tabeli jest pole descc a cały kod wygląda tak: Kod <?php
ob_start(); require 'includes/config.php'; session_start(); $number = $_GET['id']; $user = $_SESSION['user_id']; if(empty($_GET)) { echo "nie wybrano nic"; } else {?> <form method="post">Tytuł wątku: <input type="text" name="name" size="50" /><br> Opis wątku: <input type="text" name="descc" size="50" /><br> Treść: <br><textarea name="text" cols="15" rows="30"></textarea><br> <input type="submit" value="Wyslij!" /> <?php } $name=$_POST["name"]; $descc=$_POST["descc"]; $text=$_POST["text"]; $user=$_POST["user"]; echo '<pre>'; print_r($_POST); $zapis = "INSERT INTO threads (id, pid, name, 'descc', author, text, date) VALUES ('', 'x', '$name', '$descc', '$text', '$user', '')"; $wyn = mysql_query($zapis) or die(mysql_error()); $dane = mysql_fetch_array($wyn); echo "x ".$_POST["name"]." został wysłany."; ob_end_flush(); ?> Ten post edytował IceBeast 16.02.2011, 20:19:31 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 13.10.2025 - 11:27 |