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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:54:35+00:00 2026-06-07T12:54:35+00:00

I am trying to insert a row into database. All entries insert correctly, however

  • 0

I am trying to insert a row into database. All entries insert correctly, however the date is inserted as:

0000-00-00

I have tried formatting the date manually:

        $updated = $a["updated"][0];

        $updated = explode(" ", $updated);
        $updated[1] = explode("/", $updated[1]);

        $y = date('Y');
        $m = $updated[1][1];
        $d = $updated[1][0];

        $updated = $y . '-' . $m . '-' . $d;

        $updated = strtotime( $updated );
        echo '<pre>'. $updated .'</pre>';
        $upd = date('Y-m-d', $updated);

        $a["updated"][0] = $updated;            
        echo '<pre>'. $upd .'</pre>';

This is the output of the var_dump($a):

1342134000

2012-07-13

array(3) {
  ["metal"]=>
  string(6) "Silver"
  ["am"]=>
  array(3) {
    [0]=>
    string(7) "2748.00"
    [1]=>
    string(8) "1779.220"
    [2]=>
    string(8) "2253.200"
  }
  ["updated"]=>
  array(1) {
    [0]=>
    int(1342134000)
  }
}

I have also tried using mysql_date_format but the row is not inserted at all:

$updated = mysql_date_format($updated);

This is my insert query

mysql_query("INSERT INTO LondonFixes VALUES(null,'" . $a["metal"] . "','AM'," . $a["am"][1] . "," . $a["am"][0] . "," . $a["am"][2] . "," . $a["updated"][0] . ", null)");

This is my table structure

    CREATE TABLE IF NOT EXISTS `LondonFixes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Metal` varchar(10) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
  `AmPm` varchar(2) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
  `GBP` decimal(10,5) NOT NULL,
  `USD` decimal(10,5) NOT NULL,
  `EUR` decimal(10,5) NOT NULL,
  `Updated` date NOT NULL,
  `TimeStamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `Entry` (`Metal`,`AmPm`,`Updated`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=229 ;

There is probably a very simple solution to this, but go easy on me please!

  • 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-07T12:54:36+00:00Added an answer on June 7, 2026 at 12:54 pm

    Month and day require leading zero.

    Use:

    $upd = date('Y-m-d', $updated);
    

    Also be sure that your date is enclosing by quotations like string.

    ,'" . $a["updated"][0] . "'
    

    In your code you do not have quotations for the date.

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

Sidebar

Related Questions

I have an issue, I'm trying to insert a new row into a postgres
I'm trying to do a single row insert/update on a table but all the
Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
i was trying to insert a string into database having multiple value using componentsSeparatedByString:@,.
Trying to simple update a row in an SQLiteDatabase Database. I can insert records
I'm writing a plugin and trying to insert a new row into the wp_term_relationships
I'm trying to insert a row into a table that I've set up in
I'm trying to insert some files into a Postgres database. Since lots of duplication
I am trying to insert over 70,000 rows into a javascript database (using Chrome
I am trying to import email communication into a database table using Bulk Insert

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.