sc_lookup problem

Hello. I’m having trouble with sc_lookup. I’m using the following code in an Ajax On Change event;

//Lookup City and State using info from PayoffZip field
sc_lookup(my_data, “SELECT city, state FROM tblzipcodes WHERE Zip={PayoffZip}”);

{
$Payoffcity = {my_data[0][0]};
$Payoffstate = {my_data[0][1]};
}

{
echo $Payoffcity;
echo $Payoffstate;
}

// Standard Scriptcase Insertion
$insert_table = ‘tblvehicles’; // Table name
$insert_fields = array( // Field list, add as many as needed
‘PayoffCity’ => “’” . {PayoffCity} . “’”,
‘PayoffState’ => “’” . {PayoffState} . “’”,);

The echo part works and shows the correct results but my fields PayoffCity and PayoffState are not updated.

Any help greatly appreciated:)

I think at end you array there is a comma (,). Delete it.

Thanks for the response, I changed the array to:

$insert_fields = array( // Field list, add as many as needed
‘City’ => “’” . {City} . “’”,
‘State’ => “’” . {State} . “’”);

If that is what you meant it didn’t make any difference…Thanks anyway

Where are you updating it?

If you want to update a field.
{My field) = $myvalue;

I don’t see this on your code

Hi Giu, I’m using a Ajax on change event to update. I should have also said that the field names in the MySQL db tblzipcode table are city and state. the reason I’m trying to use PayoffCity and PayoffState is because I’m already using city and state elsewhere on the form. (this form has two name, address, city, state, zip fields). I put the echo commands in for testing and get the expected results, It seems the problem lies with the Insertion part. The other instance works perfectly. Hope this isn’t too confusing and thanks for responding

I insist. This is The actual code? Or a representation of the code?

With the code you posted:
You are not updating the fields. To update a field n screen you have to use {} nomenclature.if you are trying to do an insert or update, I don’t see where you build the sql and you are not firing the sentence.

Sorry, but maybe I’m missing something about what you try to do, but code posted does nothing.

I’ve attached 2 screen shots of actual code. The first (Working) works perfectly. The second (Not Working) works as far as echoing the correct response but does not do the Insert part. Hope this helps and thanks again [ATTACH=CONFIG]n69964[/ATTACH] [ATTACH=CONFIG]n69965[/ATTACH]

Working.JPG

Not Working.JPG