I can't get value of parsed variable
Posted: Mon Jan 28, 2008 3:48 am
I want to parse euro and usd values from central bank and save it to a table but result is always zero what can be the problem?
This is the code :
when i print the value on the page by writing
It prints the valu without any problem
Note : My field type is decimal(5,2) for this value on the respective table. But parse value is 3.7694 or something like this. may it be reason of the problem?
This is the code :
Code: Select all
$file = fopen("http://www.bnro.ro/Ro/Info/", "r");
$tarih = date('Y.m.d');
$today = date("d-m-Y");
$numeValuta = array("Euro","Dolarul SUA");
while (!feof($file)){
$line = fgets($file, 1024);
if (eregi('<TD class="bold">(.*)</TD>', $line, $out)) {
$cursvalutar = each($out);
while (list($key,$val) = each($numeValuta)){
if ($val == "Euro") {
$euro = str_replace(',','.',$cursvalutar[1]);
}
if ($val == "Dolarul SUA"){
$dolar = str_replace(',','.',$cursvalutar[1]);
}
break;
}
}
}
fclose($file);
$sql=mysql_query("select * from currncy where crrn_name='ron' and tarih='$tarih'");
if(mysql_num_rows($sql) == 0) {
mysql_query("INSERT INTO currncy VALUES('','$tarih','ron','$euro')") or die(mysql_error());}Code: Select all
echo $euro;Note : My field type is decimal(5,2) for this value on the respective table. But parse value is 3.7694 or something like this. may it be reason of the problem?