SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Date Problem

  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date Problem

    Hi,

    I have a problem with one of my MySQL columns, its set as DATE but whenever data is input to it throught my PHP form, the date is always set to 0000-00-00 whereas everything else that is input works fine?

    Do I need to format the date specially to get it to work?
    I have tried entering it in the format 0000-00-00 and other formats but it still doesnt work, I'd be grateful for a tip on how to sort out this problem.

    Thanks

  2. #2
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hiya

    what format are you entering the data via php? 2006-01-01?

    i am so new to this at the moment and had this problem myself you see...

    danny

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, through my PHP site Ive tried entering it in many formats, but SQL isnt accepting any of them, not even 2006-01-01 like you mention

    Oh well, I hope someoen who knows these things will help shortly

  4. #4
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    21
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What's your SQL query look like?

  5. #5
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here it is:

    PHP Code:
    if (isset($_POST['title'])) {

    $Time $_POST['Time'];
    $Date $_POST['date'];
    $Day_of_week $_POST['Day_of_week'];
    $Type $_POST['Type'];


    $sql "INSERT INTO Booking SET
        Time='
    $Time',
        Type='
    $Type',
        Date='
    $Date',
        Day_of_week='
    $Day_of_week',
        Price='
    $Price',
        Regular='
    $Regular',
        Paid='
    $Paid'";


    if (@
    mysql_query($sql)) {



    echo 
    "<p>Your Booking Details have been added.</p>";
    } else {
    echo 
    '<p>Error submitting booking details: ' .
    mysql_error() . '</p>';
    }


  6. #6
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    21
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What is the contents of $Date?

  7. #7
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $Date is set to $Date = $_POST['date'];

    where $_POST['date'] is what is entered into the field
    <input type="text" name="Date">

  8. #8
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    21
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I understand that much. Let me re-phrase. What gets printed out if you print the $Date variable right before running the query?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •