Solved

Why is this date not being inserted correctly?

Posted on 2014-12-17
2
70 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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