Announcement

Collapse
No announcement yet.

sc_lookup problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Comment


    • #3
      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

      Comment


      • #4
        Where are you updating it?

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

        I don't see this on your code
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment


        • #5
          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

          Comment


          • #6
            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.
            /Giuseppe

            Professional Scriptcase Services
            Some Customers opinions

            Comment


            • #7
              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 Working.JPG Not Working.JPG

              Comment

              Working...
              X