Please look at my code:
function getShopConfig()
{
$sql = "SELECT sc_name, sc_address, sc_phone, sc_email, sc_shipping_cost, sc_order_email, cy_symbol, sc_currency
FROM kol_shop_config , kol_currency
WHERE sc_currency = cy_id";
$result = dbQuery($sql);
$row = dbFetchAssoc($result);
if ($row) {
//extract($row);
$shopConfig = array('name' => $row['sc_name'],
'address' => $row['sc_address'],
'phone' => $row['sc_phone'],
'email' => $row['sc_email'],
'sendOrderEmail' => $row['sc_order_email'],
'shippingCost' => $row['sc_shipping_cost'],
'currency' => $row['sc_currency']);
}
return $shopConfig;
}
then im calling it like,
<td colspan="4" align="right"><?php getShopConfig(); echo $shopConfig['name'];?></td>
but nothing is being displayed.. where is the mistake?? please help.
note: both are in the same page. dbQuery() and dbFetchAssoc() functions are pre-defined and has worked properly before. if i echo it inside the function and then just call it then its working properly.
getShopConfig()function isn't being stored anywhere. The$shopConfigvariable has nothing to do with thegetShopConfig()function. For a fix, see hsz's answer below.