Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:08:39+00:00 2026-05-24T12:08:39+00:00

In form.php <html> <body> <form action=process.php method=post> <input type=text name=dat /> <input type=submit value=submit

  • 0

In “form.php”

<html>
    <body>
        <form action="process.php" method="post">
            <input type="text" name="dat" />
            <input type="submit" value="submit" />
        </form>
    </body>
</html>

In “process.php”:

<?php
    echo $_POST['dat'];

    mysql_connect("localhost", "root", "123456")
            or die("can't connect");
    mysql_select_db("st")
        or die("can't selectdb");

    $query = "INSERT INTO sts (time) VALUES ( " . $_POST['dat']. "  ) ";


    $result = mysql_query($query)
        or die(mysql_error());

    $mysql_close();

?>

This give me 0000-00-00 in the database, in the field name “time” of type “DATE”.
If using this:

$time = explode("-", $_POST['dat']);
    $query = "INSERT INTO sts (time) VALUES ( " .  date("m-d-Y", mktime(0, 0, 0, $time[1], $time[2], $time[0])). "  ) ";

-> doesn’t work either

EDIT:
I’ve changed from “m-d-Y” to “Y-m-d” for appropriate semantic, but it still doesn’t work

However, if I change the code like this:

$query = "INSERT INTO sts (time) VALUES ('1991-10-05') ";

it works.

Can anyone explain this for me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:08:39+00:00Added an answer on May 24, 2026 at 12:08 pm

    Neither if your two PHP examples have the date being quoted. They’ll generate queries that look like:

    INSERT INTO sts (time) VALUES (2009-01-02);
    

    which will be parsed down to

    INSERT INTO sts (time) VALUES (2006) 
    

    2009-01-02 is a numeric literal with two subtractions, NOT a date. To get get MySQL to treat this as a date value, it MUST be quoted:

    INSERT INTO sts (time) VALUES ('2009-01-02');
                                   ^----------^--- quotes MUST be present
    

    So your PHP should look like:

    $date = mysql_real_escape_string($_POST['dat']);
    
    $query = "INSERT INTO sts (time) VALUES ('$dat');";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
I've got a simple HTML form, thus: <html> <head></head> <body> <form action=upload_file.php method=post enctype=multipart/form-data>
Is something like this possible: <form method=post action=myphp.php name=myname target=another_html/iframe_name>??? I want the php
I have a post html form, and the action is index.php, which is the
I want to pass php variable value as a action to html form. I
index.php <!DOCTYPE html> <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <title>Form submit in php
Is it possible to to submit an HTML Form (with a PHP action) and
Here is my jQuery code: <script type=text/javascript> //<!-- $(document).ready(function() { $('input[type=submit]').click(function() { $.ajax({ type:
I have the basic html form echoed through php: <html> <body> <?php if (isset($_GET[pk]))
I have an HTML form - with PHP, I am sending the data of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.