2 Replies Latest reply on Dec 30, 2008 2:01 PM by chris.cavage

    Error when entering Date, Time

    chris.cavage Level 1
      Upon registration I have the date and time entered into mysql so I know when someone registers. I have two separate fields in my db for a specific reason.

      When I load registration.php in CS4, I get a pop-up box error: "While executing analyzeServerBehavior in InsertRecord.htm, a JavaScript error occurred." This is because of the NOW() and CURTIME() script I added to the insert record behavior.

      Is this a real problem? If so, I will address it.

      When I run my registration page and click "submit", everything works fine!

      Here is my insert code:

      if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO members (Username, Password, `First`, `Last`, Birthday, Address1, Address2, City, `State`, Zip, Phone, Email, Newsletter, Contact, Date, Time) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NOW(), CURTIME())",
      GetSQLValueString($_POST['Username'], "text"),
      GetSQLValueString($_POST['Password'], "text"),
      GetSQLValueString($_POST['First_Name'], "text"),
      GetSQLValueString($_POST['Last_Name'], "text"),
      GetSQLValueString($_POST['Birthday'], "text"),
      GetSQLValueString($_POST['Address1'], "text"),
      GetSQLValueString($_POST['Address2'], "text"),
      GetSQLValueString($_POST['City'], "text"),
      GetSQLValueString($_POST['State'], "text"),
      GetSQLValueString($_POST['Zip'], "int"),
      GetSQLValueString($_POST['Phone_Number'], "int"),
      GetSQLValueString($_POST['EMail_Address'], "text"),
      GetSQLValueString(isset($_POST['Newsletter']) ? "true" : "", "defined","'Y'","'N'"),
      GetSQLValueString(isset($_POST['contact2']) ? "true" : "", "defined","'Y'","'N'"));
        • 1. Re: Error when entering Date, Time
          Level 7
          chris.cavage wrote:
          > Upon registration I have the date and time entered into mysql so I know when
          > someone registers. I have two separate fields in my db for a specific reason.
          >
          > When I load registration.php in CS4, I get a pop-up box error: "While
          > executing analyzeServerBehavior in InsertRecord.htm, a JavaScript error
          > occurred." This is because of the NOW() and CURTIME() script I added to the
          > insert record behavior.
          >
          > Is this a real problem? If so, I will address it.

          Dreamweaver server behaviors aren't designed to handle MySQL functions.
          However, the answer to your problem is very simple. Replace the Date and
          Time columns in your table with a single column called "registered". Set
          the data type of the column to TIMESTAMP, and enter nothing into it.
          MySQL will automatically register the date and time the record was
          inserted. Use MySQL date and time functions to extract the values you
          want from the timestamp.

          By the way, you should not use Date or Time as the name for table
          columns. They are reserved words. It's also a good idea to avoid using
          uppercase in database, table, or column names, particularly if you are
          developing on Windows. The Windows version of MySQL converts all names
          to lowercase. If you then upload the database to a Linux server, all
          your code will break, because Linux servers are case-sensitive.

          --
          David Powers, Adobe Community Expert
          Author, "The Essential Guide to Dreamweaver CS4",
          "PHP Solutions" & "PHP Object-Oriented Solutions"
          http://foundationphp.com/
          • 2. Re: Error when entering Date, Time
            chris.cavage Level 1
            OOohhh.. I see. Great advice.

            Thanks so much.

            I will work on this tonight.