Jump to content

lettheflamesbegin

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lettheflamesbegin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oh, how stupid. But it didn't stand in our template.. so i asumed that that couldn't be wrong because i thought my teacher wasn't that stupid.. how wrong could i be haha Thanks everyone!
  2. Thanks, he doens't show that error anymore, but the problem now is that he doesn't add the messages into the database.. why is that? <?php $foutmelding = ''; $naam = (isset($_POST['naam'])) ? $_POST['naam'] : ''; $bericht = (isset($_POST['bericht'])) ? $_POST['bericht'] : ''; if(empty($naam)) $foutmelding = 'Vul een naam in.'; if(empty($bericht)) $foutmelding = 'Vul een bericht in.'; if (empty($error)) { $datum = date('Y-m-d'); $query = "INSERT INTO gastboek (naam, bericht, datum) VALUES ('" . $naam . "', '".$bericht."', '" . $datum . "');"; return $query; } ?> That's my code now.
  3. @GingerRobot: Thank you He now shows the messages i put into the database, the only problem i now have is with adding messages, this is the error: Notice: Undefined variable: naam in C:\Program Files\wamp\www\wp22\gastenboek\verwerkbericht.php on line 19 Notice: Undefined variable: bericht in C:\Program Files\wamp\www\wp22\gastenboek\verwerkbericht.php on line 19 It is about this part: query = 'INSERT INTO gastboek (naam, bericht, datum) VALUES (\'' . $naam . '\'. \'' . $bericht . '\'. \'' . $datum . '\');'; @Toonmariner I did what you said, and i saw my mistake: gastenboek is the wrong name, it's gastboek. Such a stupid mistake haha
  4. Hello, I'm new too the PHP language, we learn it at our school. We're working on a guestbook, but it has to be as they showed us. We have strict rules to make it, and that's where i get stuck. We have to fill in the blanks, i guess you could say. And I don't get it working, and since the teacher is sick this week and we have holiday next week, I won't see my teacher to ask him, so instead I ask it here. (I'm sorry if my English is not too good, by the way ) Here you have the code: (My databases connection is working) ----------------------index.php--------------------- <?php include ('connection.php'); if($_SERVER['REQUEST_METHOD'] == 'POST') { include ('verwerkbericht.php'); } ?> <html><head></head><body> <?php $foutmelding = mysql_error(); if(!empty($foutmelding)) echo '<p>' . $foutmelding . '</p>'; include ('toonberichten.php'); ?> <form action="index.php" method="POST"> <h3>Nieuw bericht toevoegen</h3> <p>Naam:<br /><input type="text" name="naam" /></p> <p>Bericht:<br /><textarea name="bericht"></textarea></p> <input type="submit" name="verzendknop" value="verzenden"/> </form> </body></html> ------------toonberichten.php---------------(in English: showmessages.php) <?php $query = "SELECT naam, bericht, datum FROM gastenboek ORDER BY datum DESC"; $result = mysql_query($query); echo '<table>'; while($row = mysql_fetch_array($result)) { $naam=$row['naam']; echo "de naam: $naam"; } echo '</table>'; ?> ----------------verwerkbericht.php--------------------(in English: something like addmessage.php <?php $foutmelding = ''; // $naam = (isset($_POST['naam']))''; // $bericht = (isset($_POST['bericht'])); // $email = (isset($_POST['email'])) if(empty($naam)) $foutmelding = 'Vul een naam in.'; if(empty($bericht)) $foutmelding = 'Vul een bericht in.'; if (empty($error)) { $datum = date('Y-m-d'); $query = 'INSERT INTO gastboek (naam, bericht, datum) VALUES (\'' . $naam . '\'. \'' . $bericht . '\'. \'' . $datum . '\');'; return $query; ?> If you need the example we have been given, tell me, but i don't think it's usefull to you because the explanation is dutch.. What am i doing wrong? The error i get is this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\wamp\www\wp22\gastenboek\toonberichten.php on line 8 (it's about this part in toonberichten.php: while($row = mysql_fetch_array($result)) { $naam=$row['naam']; echo "de naam: $naam"; } ) I hope you guys can help me.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.