Solved

Why is this date not being inserted correctly?

Posted on 2014-12-17
2
63 Views
Last Modified: 2014-12-17
I'm doing a basic insert statement after having scraped the data from a webpage.

When I go to insert the date, I repeatedly get "0000-00-00."

I'm grabbing the data using getElementsByTagName and it prints as 12/04/2014. But when I go to insert it into the database, it's not processing it correctly.

I figured it had to be something related to the way I was attempting to insert a string when MySQL needed a date, so I did this:

$date=date("m/d/Y", strtotime($cols->item(0)->nodeValue));

I echo-ed it, just to make sure I was barking up the right tree, and it still goes into the database as 0000-00-00.

What am I missing?
0
Comment
Question by:brucegust
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40504949
Format the date the same as MySQL is expecting it

$date=date("Y/m/d", strtotime($cols->item(0)->nodeValue));

Open in new window

0
 

Author Comment

by:brucegust
ID: 40504966
Gary, you're the man!

Had to go back and put my $date dynamic within my insert statement within "' '", but once that was in place an exasperating scenario was remedied!

Rock on!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now