This topic is locked

trouble with SQL Update

10/28/2008 6:22:29 AM
PHPRunner General questions
scuba author

I'm trying to update a mastertable when records in child are being changed. I've added this code at Events / Add page / After record added:

[codebox]global $conn;

$strUpdate = "UPDATE mastertable SET masterfield_1=".$values["childfield_1"]." WHERE id=".$values["id"];

echo $strUpdate;

db_exec($strUpdate,$conn);[/codebox]
The code seems to be alright since I don't get an error message but still the update doesn't work. Also I've experimented with INSERT INTO - no insert either??!!?? Here's what I've tried:
[codebox]global $conn,$strTableName;
$strSQLSave = "INSERT INTO mastertable WHERE id=".$values["id"]."(masterfield_1, masterfield_2) values ('";
$strSQLSave .= $values["childfield_1"]."','";

$strSQLSave .= $values["childfield_2"];
$strSQLSave .= "')";

db_exec($strSQLSave,$conn);[/codebox]
hope you guys can help me on that, it's driving me nuts and I urgently need this!! thanks for helping!!

J
Jane 10/28/2008

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

scuba author 10/28/2008

Thanks Jane, I'll do so tomorrow since I'll leave the office soon!!

R
randall 10/28/2008

I'm having a similar issue. But, I think it might be related to using MyISAM tables. Has anyone had any success with UPDATE using MyISAM and PHPRunner v4.2?

Sergey Kornilov admin 10/28/2008

MyISAM is not relevant here.
Usually you need to print SQL query on the page to see what's wrong with it.

T
thesofa 10/29/2008

Like Admin says, "echo" the sql statement to the page, then copy and paste into phpmysqladmin or Navicat and see if the statement runs and does the update.

It may be that you need to preface the field names with the table name in the query?