This topic is locked
[SOLVED]

 Need to Update field in another table

7/12/2009 4:28:52 PM
PHPRunner General questions
M
mid3vil author

How do you update a field in one table after adding information?
I have the following table site_pm with fields site_id (int) and date_pm_completed (date)
and
site_tower with fields site_id (int) and lastpm (date)
every time a user adds a date to date_pm_completed, i want to update table site_tower field lastpm where site_id's are equal
I tried using the following for event after record added but getting errors
global $conn;

$strUpdate = "UPDATE site_tower set `lastpm` = '"$values["date_pm_completed"]"' where site_id=$values["site_id"]";

db_exec($strUpdate,$conn)

return true;

Sergey Kornilov admin 7/12/2009

It would be helpful if you post exact error message here.

M
mid3vil author 7/12/2009

It would be helpful if you post exact error message here.


Parse error: syntax error, unexpected T_VARIABLE in /html/include/site_pm_events.php on line 25

Sergey Kornilov admin 7/12/2009

Try this:

$strUpdate = "UPDATE site_tower set `lastpm` = '" . $values["date_pm_completed"] . "' where site_id=" . $values["site_id"];
M
mid3vil author 7/12/2009

Try this:


$strUpdate = "UPDATE site_tower set `lastpm` = '" . $values["date_pm_completed"] . "' where site_id=" . $values["site_id"];


getting
Parse error: syntax error, unexpected T_RETURN in /html/include/site_pm_events.php on line 27

M
mid3vil author 7/12/2009

Found problem, didn't have a semicolon after
db_exec($strUpdate,$conn);
Its always the little things