hi

In PHP you get the date like this:
$today = date ("options");
where options are:
y - year, 2 digits; i.e. "99"
Y - year, 4 digits; i.e. "1999"
m - month; i.e. "01" to "12"
M - month, textual, 3 letters; i.e. "Jan"
d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
D - day of the week, textual, 3 letters; i.e. "Fri"
so date ("Y - M - d"); will return 2002 - Nov - 11.

tell me where do you what to store it (SQL, txt files, etc) and I tell you how to

    everything is stored into SQL databases, theres like 5 tables,

    id
    name
    homepage
    message
    email

    do i need to add in an extra table for date??

    thanks

      NO ...
      u don't need another table, just copy&paste the following script, save it .php on your server and point your browser to it:
      <?php
      //EDIT ONLY WHERE green
      // this is default if you instaled MySQL on your local computer
      // if not ... change 'root' with your username and '
      ****' with your password

      $conn = mysql_connect ('localhost' , 'root' , '*****') or die ("Could not connect ... please check username and password");

      // enter the name of your database
      $db = mysql_select_db ('your_database_name_here') or die ("No database ... please check that you typed your database name correctly");

      //please enter the table_name (only the table_name)
      $alter_table = mysql_query ("ALTER TABLE your_table_name_here add date datetime");

      ?>

      Now ... when you insert data into the Database ... your script must look something like this:

      mysql_query ("INSERT INTO table_name VALUES ('', '$name'.....)");
      or
      mysql_query ("INSERT INTO table_name ('id', 'name' ...) VALUES ('', '$name')");
      mysql_query ("INSERT INTO table_name SET id = '', name ='$name' ....");

      Find that line and add this :
      - if it's the first example:
      mysql_q......VALUES (''....,'$date')");
      - if seccond exapmle
      mysql_q......('id'....,date) VALUES (''....'$date')");
      - or last
      mysql_q......SET id = '' , '$nam......., date = '$date' ");

        Thanks,

        I did all that but now the dates going into the database as

        0000-00-00 00:00:00

        :S

        If i was more intelligent in the world of programming i could probably figure this out!!!!

        But...

        LOL

          sorry I forgat

          add this code to the insert page- the page with insert into ...., before the insert statement

          $date = date ("Y-m-d G:i:s");

            yikes now im getting parse errors and stuff. Ill post what Ive done and you can check wot i did wrongπŸ˜ƒ haha i feel so dumb.

            
            <head>
            <meta http-equiv=\"refresh\" content=\"0;URL=?page=guestbook\"><meta http-equiv=\"refresh\" content=\"0;URL=?page=guestbook\">
            </head>
            
            <?php
            
            
            
              $link = mysql_connect("localhost", "********", "********");
            
              mysql_select_db("*********");
            
            
            
            if ($action == post) {
            
              $query = "SELECT * FROM book_b order by ID";
            
              $result = mysql_query($query);
            
            
            
              while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
            
              foreach ($line as $col_value) {
            
              $x++;
            
            
            
               if ($x == 1) {
            
            $ID_c = $col_value;
            
               }
            
            
            
               if ($x == 2) {
            
            $POSTS = $col_value;
            
               }
            
             }
            
            
            
             if (!$name || !$message) {
            
              print "Please Fill in Both Name and Message Fields.\n";
            
              print "\n";
            
             }
            
             else {
               $date = date ("Y-m-d G:i:s");
               mysql_query("INSERT INTO book (ID, NAME, EMAIL, URL, MESSAGE, date) VALUES ('', '$name', '$email', '$url', '$message', &date')");
            
               $POSTS = $POSTS + 1;
            
            
               mysql_query("UPDATE book_b SET posts = '$POSTS' WHERE id = '1'");
            
            
            
              print "Your Message has been Posted. Thank You.\n";
            
              print "\n";
            
              $x =0;
            
             }
            
             }
            
            }
            
             else {
            
            ?>
            
            <form method="post" action="?page=guestbook&amp;action=post">
            
              <table width="420" cellspacing="1" cellpadding="1" align="center">
            
            <tr> 
            
              <td width="50%"><b>Name: 
            
                <input type="text" name="name" size="20">
            
                </b></td>
            
              <td width="50%"><b>Site: 
            
                <input type="text" name="url" size="20">
            
                </b></td>
            
            </tr>
            
            <tr> 
            
              <td colspan="2"><b>E-Mail: 
            
                <input type="text" name="email" size="30">
            
                </b></td>
            
            </tr>
            
            <tr valign="top"> 
            
              <td colspan="2"><b>Message:<br>
            
                <textarea name="message" cols="55" rows="4"></textarea>
            
                </b></td>
            
            </tr>
            
            <tr> 
            
              <td colspan="2"> 
            
                <div align="center"><br>
            
                  <input type="submit" name="Submit" value="  Submit Message  ">
            
                  <input type="reset" name="Submit2" value="  Reset  ">
            
                </div>
            
              </td>
            
            </tr>
            
              </table>
            
            </form>
            
            <div align="center">
            
            <?php
            
              $query = "SELECT * FROM book_b order by ID";
            
              $result = mysql_query($query);
            
            
            
              while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
            
              foreach ($line as $col_value) {
            
              $x++;
            
            
            
               if ($x == 1) {
            
            $ID_c = $col_value;
            
               }
            
            
            
               if ($x == 2) {
            
            $POSTS = $col_value;
            
               }
            
             }
            
            
            
              print "$POSTS Messages have been Posted\n";
            
              $x =0;
            
            }
            
            
            
              $query = "SELECT * FROM book order by ID DESC";
            
              $result = mysql_query($query);
            
            
            
              while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
            
              foreach ($line as $col_value) {
            
              $x++;
            
            
            
               if ($x == 1) {
            
            $ID = $col_value;
            
               }
            
            
            
               if ($x == 2) {
            
            $NAME = $col_value;
            
               }
            
            
            
               if ($x == 3) {
            
            $EMAIL = $col_value;
            
               }
            
            
            
               if ($x == 4) {
            
            $URL = $col_value;
            
               }
            
            
            
               if ($x == 5) {
            
            $MESSAGE = $col_value;
            
               }
            
             ?>
            
              <table width="420" cellspacing="1" cellpadding="1">
            
            <tr bgcolor="#DDDDDD"> 
            
              <td> 
            
                <table width="100%" cellpadding="0" cellspacing="0">
            
                  <tr>
            
                    <td width="50%" bgcolor="#FF0000"><?php print "<a href=\"mailto:$EMAIL\">$NAME</a>\n"; ?></td>
            
                    <td width="50%" bgcolor="#FF0000"> 
            
                      <div align="right"><?php print "<a href=\"$URL\" target=\"_blank\">$URL</a>\n"; ?></div>
            
                    </td>
            
                  </tr>
            
                </table>
            
              </td>
            
            </tr>
            
            <tr> 
            
              <td>&nbsp;<?php print "$MESSAGE\n"; ?></td>
            
            </tr>
            
            <tr> 
            
            
            
            </tr>
            
              </table>
            
              <?php
            
              $x =0;
            
             }
            
            }
            ?>

              get $date = date ("Y-m-d G:i:s"); out from the else statement ....
              move it up right under <?PHP

              <?php
              
               $date = date ("Y-m-d G:i:s");
              
                $link = mysql_connect("localhost", "********", "********");
              
                

              ........
              Change

                 mysql_query("INSERT INTO book (ID, NAME, EMAIL, URL, MESSAGE, date) VALUES ('', '$name', '$email', '$url', '$message', &date')");
              

              to

                 mysql_query("INSERT INTO book (ID, NAME, EMAIL, URL, MESSAGE, date) VALUES ('', '$name', '$email', '$url', '$message', '$date')");
              

              this must work. If you get parse errors copy&paste theme here

                
                <head>
                <meta http-equiv=\"refresh\" content=\"0;URL=?page=guestbook\"><meta http-equiv=\"refresh\" content=\"0;URL=?page=guestbook\">
                </head>
                
                <?php
                $date = date ("Y-m-d G:i:s");
                
                
                  $link = mysql_connect("localhost", "*********", "********");
                
                  mysql_select_db("castlefm_net");
                
                
                
                if ($action == post) {
                
                  $query = "SELECT * FROM book_b order by ID";
                
                  $result = mysql_query($query);
                
                
                
                  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
                
                  foreach ($line as $col_value) {
                
                  $x++;
                
                
                
                   if ($x == 1) {
                
                $ID_c = $col_value;
                
                   }
                
                
                
                   if ($x == 2) {
                
                $POSTS = $col_value;
                
                   }
                
                 }
                
                
                
                 if (!$name || !$message) {
                
                  print "Please Fill in Both Name and Message Fields.\n";
                
                  print "\n";
                
                 }
                
                 else {
                
                   mysql_query("INSERT INTO book (ID, NAME, EMAIL, URL, MESSAGE, date) VALUES ('', '$name', '$email', '$url', '$message', '$date')");
                   $POSTS = $POSTS + 1;
                
                
                   mysql_query("UPDATE book_b SET posts = '$POSTS' WHERE id = '1'");
                
                
                
                  print "Your Message has been Posted. Thank You.\n";
                
                  print "\n";
                
                  $x =0;
                
                 }
                
                 }
                
                }
                
                 else {
                
                ?>
                
                <form method="post" action="?page=guestbook&amp;action=post">
                
                  <table width="420" cellspacing="1" cellpadding="1" align="center">
                
                <tr> 
                
                  <td width="50%"><b>Name: 
                
                    <input type="text" name="name" size="20">
                
                    </b></td>
                
                  <td width="50%"><b>Site: 
                
                    <input type="text" name="url" size="20">
                
                    </b></td>
                
                </tr>
                
                <tr> 
                
                  <td colspan="2"><b>E-Mail: 
                
                    <input type="text" name="email" size="30">
                
                    </b></td>
                
                </tr>
                
                <tr valign="top"> 
                
                  <td colspan="2"><b>Message:<br>
                
                    <textarea name="message" cols="55" rows="4"></textarea>
                
                    </b></td>
                
                </tr>
                
                <tr> 
                
                  <td colspan="2"> 
                
                    <div align="center"><br>
                
                      <input type="submit" name="Submit" value="  Submit Message  ">
                
                      <input type="reset" name="Submit2" value="  Reset  ">
                
                    </div>
                
                  </td>
                
                </tr>
                
                  </table>
                
                </form>
                
                <div align="center">
                
                <?php
                
                  $query = "SELECT * FROM book_b order by ID";
                
                  $result = mysql_query($query);
                
                
                
                  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
                
                  foreach ($line as $col_value) {
                
                  $x++;
                
                
                
                   if ($x == 1) {
                
                $ID_c = $col_value;
                
                   }
                
                
                
                   if ($x == 2) {
                
                $POSTS = $col_value;
                
                   }
                
                 }
                
                
                
                  print "$POSTS Messages have been Posted\n";
                
                  $x =0;
                
                }
                
                
                
                  $query = "SELECT * FROM book order by ID DESC";
                
                  $result = mysql_query($query);
                
                
                
                  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
                
                  foreach ($line as $col_value) {
                
                  $x++;
                
                
                
                   if ($x == 1) {
                
                $ID = $col_value;
                
                   }
                
                
                
                   if ($x == 2) {
                
                $NAME = $col_value;
                
                   }
                
                
                
                   if ($x == 3) {
                
                $EMAIL = $col_value;
                
                   }
                
                
                
                   if ($x == 4) {
                
                $URL = $col_value;
                
                   }
                
                
                
                   if ($x == 5) {
                
                $MESSAGE = $col_value;
                
                   }
                
                 ?>
                
                  <table width="420" cellspacing="1" cellpadding="1">
                
                <tr bgcolor="#DDDDDD"> 
                
                  <td> 
                
                    <table width="100%" cellpadding="0" cellspacing="0">
                
                      <tr>
                
                        <td width="50%" bgcolor="#FF0000"><?php print "<a href=\"mailto:$EMAIL\">$NAME</a>\n"; ?></td>
                
                        <td width="50%" bgcolor="#FF0000"> 
                
                          <div align="right"><?php print "<a href=\"$URL\" target=\"_blank\">$URL</a>\n"; ?></div>
                
                        </td>
                
                      </tr>
                
                    </table>
                
                  </td>
                
                </tr>
                
                <tr> 
                
                  <td>&nbsp;<?php print "$MESSAGE\n"; ?></td>
                
                </tr>
                
                <tr> 
                
                
                
                </tr>
                
                  </table>
                
                  <?php
                
                  $x =0;
                
                 }
                
                ?>

                I still get parse errors

                Parse error: parse error in /home/sites/site113/web/guestbook.html on line 289

                Thats the precise error I get..

                  just bumping this back up, is there anyone here that can help cos this guestbook is very very very important and it has stopped working all together πŸ™

                    Write a Reply...