Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why is this date not being inserted correctly?

Posted on 2014-12-17
2
Medium Priority
?
77 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

715 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