Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

[SOLVED] DAL Update query error

$
0
0
Hi,

I am trying to update currency values on application initialization, I have created following code on After Application Initialized event :

$veri=simplexml_load_file("http://www.tcmb.gov.tr/kurlar/today.xml");
$dolartl_s=(string)$veri->Currency[0]->BanknoteSelling;
$eurtl_s=(string)$veri->Currency[3]->BanknoteSelling;
$gbptl_s=(string)$veri->Currency[4]->BanknoteSelling;
$dolartl=(string)$veri->Currency[0]->BanknoteBuying;
$eurtl=(string)$veri->Currency[3]->BanknoteBuying;
$gbptl=(string)$veri->Currency[4]->BanknoteBuying;
$_SESSION["UsdTrl"]=$dolartl;
$_SESSION["EurTrl"]=$eurtl;
$_SESSION["GbpTrl"]=$gbptl;
$_SESSION["UsdTrl_s"]=$dolartl_s;
$_SESSION["EurTrl_s"]=$eurtl_s;
$_SESSION["GbpTrl_s"]=$gbptl_s;

global $dal;
$tblcurrencies= $dal->Table("mu_currencies");
$rs = $tblcurrencies->Query("Active='1'");
while( $data = db_fetch_array($rs) )

{
$query = "UPDATE mu_currencies SET ";

if ($currency_code == "USD"){
    $query .= "`value_buy` = '$dolartl', `value_sell` = '$dolartl_s' ";
}

if ($currency_code == "EUR"){
    $query .= "`value_buy` = '$eurtl', `value_sell` = '$eurtl_s' ";
}

if ($currency_code == "GBP"){
    $query .= "`value_buy` = '$gbptl', `value_sell` = '$gbptl_s' ";
}

    $query .= "WHERE `currency_code` = ".$data["currency_code"];
}
CustomQuery($query);


The code is not returning any syntax error while compiling. But when I am opening the web page the following error preventing to open the page:

Quote

Fatal error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `currency_code` = USD' at line 1 in /volume1/Web/property/connections/Connection.php on line 661


Can someone tell me what is missing??

Viewing all articles
Browse latest Browse all 2586

Trending Articles