You are here:  » cannot enter or appear some values


cannot enter or appear some values

Submitted by paschalis on Mon, 2007-11-12 16:57 in

Hi Guys,

when i take a date (i.e $startDate) and try to printit before the function myRecordHandler($record) the date appears corectly (the format is 20071112052015). When i try to print it inside the function myRecordHandler($record) it cannot be appeard. I am desperate for your help.

this an example of my code ...

<?php
$time 
time()+$SETTINGS['timecorrection']*3600;
$startDate date("YmdHis",$time);
print 
$startDate;
require(
"MagicParser.php");
function 
myRecordHandler($record)
{
  
$title $record["product"];
  
$descr $record["description"];
  
$image $record["imageurl"];
  
$price $record["price"];
  print 
$startDate;
}
MagicParser_parse("name_of_file.csv","myRecordHandler","csv|124|1|0");
?>

Thank you in advance

Paschalis

Submitted by support on Mon, 2007-11-12 17:00

Hi Paschalis,

You need to declare $startDate as global within myRecordHandler. The following should work:

<?php
$time 
time()+$SETTINGS['timecorrection']*3600;
$startDate date("YmdHis",$time);
print 
$startDate;
require(
"MagicParser.php");
function 
myRecordHandler($record)
{
  global 
$startDate;
  
$title $record["product"];
  
$descr $record["description"];
  
$image $record["imageurl"];
  
$price $record["price"];
  print 
$startDate;
}
MagicParser_parse("http://www.e-shop.gr/sql/feed/products_desc_rest.csv","myRecordHandler","csv|124|1|0");
?>

Cheers,
David.

Submitted by paschalis on Tue, 2007-11-13 15:32

it worked perfectly ... thanks