The following inserts til' I add the IF condition on $dateval.
Want to insert only if the record DATE on xml is >= specified date per insert, to avoid duplicates
The date formats agree.
Have tried: single and double and not quotes for 2009-06-17
Have tried with and without declaring the variable 1st.
Have also tried this as a WHERE clause
Is it likely there is confusion between xml DATE and mysql date ?
Do xml dates -- 0000-00-00 need 'mysql_real_escape_string' ?
PHP Code:
require("xmlP/Parser.php");
$filename = "http://site.com/feeds/mysite.xml";
function Handler($record)
$dateval = ".mysql_real_escape_string( $record["DATE"] ).";
$sql =
if ($dateval >= '2009-06-17'){
$sql = " INSERT INTO Stores SET
STitle = '".mysql_real_escape_string( $record["TITLE"] )."',
SDescription = '".mysql_real_escape_string( $record["DESCRIPTION"] )."',
SReference = '".mysql_real_escape_string( $record["REFERENCE"] )."',
SCity = '".mysql_real_escape_string( $record["CITY"] )."',
SState = '".mysql_real_escape_string( $record["STATE"] )."',
SfeedDate = '".mysql_real_escape_string( $record["DATE"] )."',
SloadDate = '".date('Y-m-d')."'";
mysql_query($sql) or die(mysql_error());
echo "Inserted";
}
My_parse($filename,"Handler","xml|source/shops/");
Bookmarks