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 9187109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:41:32+00:00 2026-06-17T19:41:32+00:00

I am new to php just to warn you. Anyway I’ve looked this up

  • 0

I am new to php just to warn you. Anyway I’ve looked this up a bunch but seeing as I don’t understand too much.. I can’t see how to do this..
So I have a table with a ‘date’ column in it, and I am testing out using a form to insert values into the table.. I wanted to have it so I could split the date up in the form, (eg month: day: year) and have it combine them into one value to insert into the ‘date’ column.. any ideas how to do this?? I’d tried implode() but I’m not sure exactly how the values are sent from the form so..
With the codes:

The actual form

    <form action="submit.php" method="post" style="text-align: center; width: 550px; margin: auto;">
        <!--Id: <input type="text" name="id"> -->
        <div style="float: left;">Author: <input type="text" name="author"></div>
        <div style="float: right;">Month: <input type="text" name="month" size="3">
        Day: <input type="text" name="day" size="3">
        Year: <input type="text" name="year" size="5"><br></div>
        <textarea name="post" style="width: 550px; height: 100px;"></textarea><br>
        <input type="submit">
    </form>

</body>

the Submit.php

<?php

mysql_connect('localhost','root');
mysql_select_db('apple');

$date = implode("-", "(month, day, year)");

$sql = "INSERT INTO blog (id, author, $date, post) VALUES ('$_POST[id]', '$_POST[author]', '$_POST[date]', '$_POST[post]')";

if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
?>
  • 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-06-17T19:41:33+00:00Added an answer on June 17, 2026 at 7:41 pm

    implode() takes an array as its second parameter:

    $date = implode("-", array($_POST['year'], $_POST['month'], $_POST['day']));
    

    You can also use sprintf():

    $date = sprintf("%04d-%02d-%02d", $_POST['year'], $_POST['month'], $_POST['day']);
    

    There’s also two problems with your query. Try this:

    $sql = "INSERT INTO blog (id, author, `date`, post) 
            VALUES ('$_POST[id]', '$_POST[author]', '$date', '$_POST[post]')";
    

    A few other points:

    • The date data type in MySQL is YYYY-MM-DD
    • You’re wide open to SQL injections
    • Don’t use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi – this article will help you decide which. If you choose PDO, here is a good tutorial.
    • The word date is reserved in MySQL. You should try to avoid naming columns after reserved words. It’s asking for problems.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty new to PHP and MySQL and I just can't figure this
Well I just started using this new php PDO, and am having this issue.
We just switched to new PHP SDK and JS today. but the problem is
I am new to PHP, I practised PHP setcookie() just now and failed. http://localhost/test/
I'm new to PHP development and I just used Zend yesterday. One problem I'm
I've just started messing around with php recently and I was testing my new
New to PHP and MySQL, have heard amazing things about this website from Leo
Rather new to php, so sorry if this seems stupid. I'm really copying a
I'm fairly new to PHP, so I'm sorry if this is a dumb question.
To be more clear, I do understand how to create a new php file

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.