This topic is locked

newbie question about declaring / passing variables

8/21/2008 6:27:39 PM
PHPRunner General questions
R
rsmuckles author

Greetings,
I have a table that represents companies and a table that represents contacts. I must have separate tables so that a company can have multiple contacts. My employer has requested that when editing a company record the ability to add a contact that is linked with the company is available by the use of a button.
I added a button to the edit_companies form which automatically goes to the add_contact form.
I need to pass the 'record_id' value to the add_contact form, so that I can set that value in the new contact record using an 'After record added' event.
I have searched the forum here and I have tried using the following code to set the variable:
attempt #1:

$_SESSION["pass_to_contact"] = $data["record_id"];
attempt #2:

$_SESSION["pass_to_contact"] = $values["record_id"];
attempt #3:

global $conn;

$strSQL = "select `record_id` from `companies` where `id` = ";

$strSQL .= $value["id"];

$rs = db_query($strSQL,$conn);

$data = db_fetch_array($rs);

$_SESSION["pass_to_contact"] = $data["record_id"];
I tried each of the above solutions both as a custom event and an EditOnLoad event in the edit_companies.
I response to each of the above attempts I receives the same PHP error #8 message:
Undefined variable: pass_to_contact
referring to the code in contacts_events.php in which I try to use the variable to update the contacts table:
global $conn;
$strSQLInsert = "UPDATE `contacts` SET `record_id` = '";
$strSQLInsert .= $rec_id_to_contact;

$strSQLInsert .= "'";

//db_exec($strSQLInsert,$conn);
echo "
".$strSQLInsert."</p>";
It's very possible that I'm missing something obvious . . . I'm a hardware guy who was stuck with this job and have close to zero programming background. If someone can explain how this might be done I'd be really grateful -
John
I'm using PHPRunner 4.2 build 379

J
Jane 8/22/2008

Hi,
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.