• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Problem mit $_GET

So:
Code:
if(isset($_POST["commentOk"]))
    {
        include "include/design/db_connect.php";
        
        $cName = $_POST['name'] ;
        $cText = $_POST['text'];
        $aID = $_GET['bid'];
        $cDate = date("Y.m.d");
        
        if($cName == "" or $cText == "")
        {
            echo "Du hast nicht alle Felder ausgefüllt.";
        } else {
             $query = "INSERT
                INTO
                   `comments`
                SET
                  `aID` = "   . mysql_real_escape_string($_GET["bid"]) . ",
                  `author` = '" . mysql_real_escape_string($_POST['name']) . "',
                  `text` = '" . mysql_real_escape_string($_POST['text']) . "',
                  `date`=now()";


    mysql_query($query)
       or die ("MySQL-Error: " . mysql_error());
        }
        mysql_close($verbindung);
    }

Und das Formular:
<form action="index.php?page=blog&bid=<?php $_GET['bid'] ?>" method="post">

Und die Errormeldung:
MySQL-Error: 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 ' `author` = 'dfgdf', `text` = 'fbdfb', ' at line 5

Ich weiß echt nicht mehr weiter...
 
Ich bezweifele, dass bid richtig an der URL hängt. Baue ein hidden-Feld bid ins Formular ein und im Script nimmst du $_POST['bid'] und überprüfe auf Existenz und Wert.
 
Ja. Habe ich grade gemacht:
Code:
<form action="index.php?page=blog" method="post">
                                Name:</br>
                                <input type="text" name="name"><input type="hidden" value="<?php $_GET['bid'] ?>" name="blogid"></br>
                                Kommentar:</br>
                                <textarea id="area" name="text"></textarea></br>
                                <input type="submit" name="commentOk" value="Senden"></br>
                            </form>
Ich habe das Feld grademal auf text gestellt, aber im Browser ist es leer.
 
Zurück
Oben