On_updateon_insert from Sql not working

QuestionsOn_updateon_insert from Sql not working
Joel Gomes asked 8 years ago

Hello
Im trying to save data on_update/on_insert from a query but i cant get this to work, he saves all fields that i ask but not ["ex_rate1"].

my code:

$result1 = mysql_query("select * from angola_ex_rate WHERE active = '1'") or die (mysql_error());
$row = mysql_fetch_array ($result1);

$e["on_insert"] = array("add_rec", null, true);
function add_rec($data)
{
$data["params"]["INVOICER"] = $_SESSION["username"];

$data["params"]["INVOICE_DATE"] = strftime("%F %T");

$data["params"]["ex_rate"] = $row["ex_rate1"];
}

$e["on_update"] = array("update_rec", null, true);
function update_rec($data)
{
$data["params"]["INVOICER"] = $_SESSION["username"];

$data["params"]["INVOICE_DATE"] = strftime("%F %T");

$data["params"]["ex_rate"] = $row['ex_rate1'];
}

2 Answers
Abu Ghufran answered 8 years ago

The variable $row is outside the scope of function.
You must declare it as global to use inside.

function ….
{
global $row;

}

juliano gomes weber answered 8 years ago

Dammm
so easy, thank you so mutch

Your Answer

19 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?