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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:01:08+00:00 2026-06-05T07:01:08+00:00

I am trying to insert a date from a variable into a mysql database.

  • 0

I am trying to insert a date from a variable into a mysql database. The format of the column is date and it has dates in the column. The dates in the column look like yyyy-mm-dd

my date variable also looks like this however it will not insert the date into the column and even i do not get an error just a white screen.

<?php
//here is the code to insert this does not work
mysql_query("INSERT INTO `invoices` (account_id, purchased_date, sales_rep, INV_ID)
VALUES ('".$acctid."', '".$date"','".$row['8']."', '".$invid."' )") or die("load1 -" . mysql_error());

<?php 
//this does work but it does not have the date.
mysql_query("INSERT INTO `invoices` (account_id, sales_rep, INV_ID)
    VALUES ('".$acctid."', '".$row['8']."', '".$invid."')") or die("load1 -" . mysql_error());

not sure what the problem is. I have displayed the $date variable onto the screen and it looks fine ex. 2012-06-01

so I am not sure why it can not insert this into the database.

  • 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-05T07:01:10+00:00Added an answer on June 5, 2026 at 7:01 am

    Your error is that you have a parse error in this line:

    VALUES ('".$acctid."', '".$date"','".$row['8']."', '".$invid."' )")
    

    Your server has display_errors turned off, so you’re not seeing the fatal error output.

    You can fix it by adding a concatenation operator (.) like so:

    VALUES ('".$acctid."', '".$date."','".$row['8']."', '".$invid."' )")
    

    Also, in the future, I find it more readable to write my queries like so:

    VALUES ('{$acctid}', '{$date}', '{$row['8']}', '{$invid}')
    

    If you prefer not to use interpolation (that’s the method of string “injection” used above), you could still use concatenation (your original method) but use spaces to make it more readable (and easier to find syntax errors before you try to execute it):

    "VALUES ('" . $acctid . "', '" . $date . "' , '" . $row['8'] . "', '" . $invid . "')";
    

    And before all the haters shun me for suggesting interpolation over concatenation, let me refer you to this tweet by @rasmus stating that interpolation is actually faster than concatenation, these days.

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

Sidebar

Related Questions

I'm trying to insert date with MM/dd/yyyy Format into a date format field in
I am trying to insert a future date into a MySQL table from PHP.
I'm trying to insert the current date from a php form into a database.
I'm trying to insert records with YYYY-MM-DD HH:MM:SS format into Oracle from Netezza, but
I am trying to insert date into a table but the date and format
I am trying to insert date in table in format DD.MM.YYYY, How do I
I've got a typical problem when trying to insert a date into MySQL. The
I'm trying to insert the data into my database which has 2 tables Products
Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,

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.