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

  • Home
  • SEARCH
  • 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 196709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:47:26+00:00 2026-05-11T16:47:26+00:00

I am trying to insert to date,time fields using a php script but I

  • 0

I am trying to insert to date,time fields using a php script but I am getting a syntax error. Can someone please tell me, where I am doing the mistake.
Thanks fellows

INSERT INTO calendar(event,from,to,day)
VALUES
(‘”.$_REQUEST[‘event’].”‘,
‘”.$_REQUEST[‘from_time’].”‘,
‘”.$_REQUEST[‘to_time’].”‘,
‘”.$_REQUEST[‘date_event’].”‘)

  • 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-11T16:47:26+00:00Added an answer on May 11, 2026 at 4:47 pm

    Never insert string data into your sql statement without sanitizing the data or you end up with sql injections (intentional or unintentional injections), see http://php.net/mysql_real_escape_string
    If you do not have a debugger installed, let php print the sql statement so you can inspect it.

    Format and indent your sql queries. They are much easier to read and debug that way.

    Always check the return value of mysql_query(). If it’s FALSE the query failed and mysql_errno() or mysql_error() can tell you more about the cause of the error.

    If you want to use an identifier that is also a reserved word for MySQL you almost always must put it in backticks (`) or double_quotes (in ansi mode).

    The format of date/time literals understood by MySQL is explained at http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html

    Using _REQUEST for INSERT operations may be questionable …but I leave that to others to answer 😉

    <?php
    $mysql = mysql_connect...

    $query = "
    INSERT INTO
    `calendar`
    (`event`, `from`, `to`, `day`)
    VALUES
    (
    '" . mysql_real_escape_string($_REQUEST['event'], $mysql) ."',
    '" . mysql_real_escape_string($_REQUEST['from_time'], $mysql) ."',
    '" . mysql_real_escape_string($_REQUEST['to_time'], $mysql) ."',
    '" . mysql_real_escape_string($_REQUEST['date_event'], $mysql]) ."'
    )
    ";
    echo '<pre>$query=', htmlspecialchars($query), '</pre>';
    $result = mysql_query($query, $mysql);
    if ( !$result ) {
    echo 'error: ', mysql_error($mysql);
    }And btw: Use prepared statements instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 190k
  • Answers 190k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You may also want to check out the .live keyword… May 12, 2026 at 6:00 pm
  • Editorial Team
    Editorial Team added an answer It depends on how the string is going to wind… May 12, 2026 at 6:00 pm
  • Editorial Team
    Editorial Team added an answer Delegates are like function pointers. Take a look at this… May 12, 2026 at 6:00 pm

Related Questions

I am trying to insert a time only value, but get the following error
I am trying to convert an access datetime field to a mysdl format, using
I am trying to insert a record into a table using Linq but get
OK, I have just been reading and trying for the last hour to import

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.