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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:20:42+00:00 2026-06-08T12:20:42+00:00

Hi im learning php and mySQL and im having issues with inserting or updating

  • 0

Hi im learning php and mySQL and im having issues with inserting or updating dates into MySQl.

The error i get back is usually something like:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’08:17:00, 2012-07-12 08:17:00, 2012-07-12 08:17:00, 2012-07-12 08:17:00

I have 4 date entries hence the reason for 4 dates above. So the date seems to be going in but there is an issue with the time.
In my datebase im using datetime.

Here is my code, i filtered out the uneccessary stuff as everything else inserts fine if i comment out the date inserts.

$end_date = ($_POST['end_date']);
$end_date = date('Y-m-d H:i:s',strtotime($end_date));

Insert Query is simply:

mysql_query("INSERT INTO deals (end_date) 
VALUES ('$end_date')") 

or die(mysql_error());  

Now ive literally spent hours researching this and tried a bunch of combinations without luck, one solution i did apply to an update was this which worked fine but im not sure how to apply it to an insert since i dont need the 3 days added in this scenario and im thinking better to get this date issue sorted out now while im learning.

$sql = "UPDATE deals SET deal_end_date = DATE_ADD(now(), INTERVAL $my_expiry DAY)";

Now my style of learning was to watch a 40 hour tutorial on the basics and then make a website and for each part of the website i come across a different problem, i research how to code it and learn a bit at a time. I find this so much more motivating than reading a manual.

Would appreciate any help. Because im learning maybe dumb down the code to make it more readable, i can look into stripping down the code later but i want to try and understand it better and if the solution is in more readable format that will help.

  • 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-08T12:20:43+00:00Added an answer on June 8, 2026 at 12:20 pm

    The way you compose the query elads to an invaid syntax. Try to dump the composed string instead for debugging purposes, you will find that the quotes are wrong.

    WRONG:

    INSERT INTO deals (end_date) VALUES ('2012-07-12 08:17:00, 2012-07-12 08:17:00, 2012-07-12 08:17:00');
    

    Correct would be something like:

    INSERT INTO deals (end_date) VALUES ('2012-07-12 08:17:00', '2012-07-12 08:17:00', '2012-07-12 08:17:00');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, slowly progressing on learning php and mysql and get stuck on every step.
I'm learning PHP and MySQL to get a hang of server-side scripting and for
So I'm learning PHP with MYSQL right now. Making a user registration and mail
I am learning PHP and tried to connect to MySQL. Altough I am using
I need to run Linux-Apache-PHP-MySQL application (Moodle e-learning platform) for a large number of
I've developed an open source application in php and mysql. I'd like to give
I'm learning php through head first's php and mysql and I'm toying with the
I'm currently learning PHP and MySQL and I have been working from a basic
I'm learning web-centric programming by writing myself a blog, using PHP with a MySQL
I have just started learning MySQL and am having trouble extracting matching flights from

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.