Announcement

Collapse
No announcement yet.

[SOLVED] HELP !!! How to echo/print an array

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

  • [SOLVED] HELP !!! How to echo/print an array

    Hi have to see the content of array as result of mySQL select. I did lot of test but no way.. Which is the sintax I have to use ?
    The query work perfectly and echo $$check_sql is nice.

    $check_sql = "SELECT memberName, contactLastName,
    borndate, bornplace, members.phone, members.mobile01, members.addressLine1,
    members.city, members.postalCode, members.fiscalcode, license_card_01,
    offices.officedesc, offices.code01, offices.city
    FROM members LEFT OUTER JOIN offices ON members.officeID = offices.officeID
    WHERE memberID = {event_member}";

    sc_select(dataset, $check_sql);
    print_r(array_values(?????????));

    I did also echo " 0 " . '{dataset[0][0]}' . " 1 " . '{dataset[0][0]}' ........

    After the array I have an UPDATE comand like following:

    $update_table = 'events_rows'; // Table name
    $update_where = "event_row_ID = [glo_event_row_ID]"; // Where clause
    $update_fields = array( // Field list, add as many as needed
    "`event_subscriber_surname` = '{dataset[0][1]}'",
    "`born_to` = '{dataset[0][3]}' ",
    "`born_date` = '{dataset[0][2]}'",
    "`city` = '{dataset[0][7]}' ",
    "`zipcode` = '{dataset[0][8]}' ",
    "`address` = '{dataset[0][6]}' ",
    "`phone` = '{dataset[0][4]}'",
    "`office` = '{dataset[0][11]}'",
    "`office_code` = '{dataset[0][12]}' ",
    "`office_city` = '{dataset[0][13]}' ",
    "`license_nr` = '{dataset[0][10]}' ",
    "`fiscal_code` = '{dataset[0][09]}' ",
    );

    // Update record
    $update_sql = 'UPDATE ' . $update_table
    . ' SET ' . implode(', ', $update_fields)
    . ' WHERE ' . $update_where;
    sc_exec_sql($update_sql);

    Result is that SC write in all listed field the same content as the lenght of field:
    "memberName,contactLastName,borndate,bornplace,pho ne,mobile01,add" ... on each field.

    ??? Where is the mistake ??
    Attached Files

  • #2
    The whole array;
    print_r({dataset});

    The second field in first record:
    print_r({dataset}[0][1]);
    Last edited by RHS; 08-16-2013, 03:23 PM. Reason: {} inserted ...
    Best regards: - Reinhard -

    I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

    Comment


    • #3
      Hi, Thank,
      the echo {dataset[0][0]}; print ---> $this->dataset[0][0] . Does it mean that array is not correct ? But why if I run the query under mySQL works nice ?

      Have you got idea becouse update write the sql language of query insteat of values of fields ?

      Comment


      • #4
        Originally posted by giovannino View Post
        the echo {dataset[0][0]}; print ---> $this->dataset[0][0] . Does it mean that array is not correct ?
        No. {dataset} is identical to $this->dataset, {dataset}[0][0] hence identical to $this->dataset[0][0].
        Best regards: - Reinhard -

        I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

        Comment


        • #5
          Originally posted by giovannino View Post
          ??? Where is the mistake ??
          wrong: {dataset[0][1]}

          correct: {dataset}[0][1] or $dataset[0][1] or $this->dataset[0][1]
          Best regards: - Reinhard -

          I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

          Comment


          • #6
            OK, thanks. I've transformed all into vars.
            $ds0 = {ds[0][0]}; $ds1 = {ds[0][1]}; $ds2 = {ds[0][2]};
            $ds3 = {ds[0][3]}; $ds4 = {ds[0][4]}; $ds5 = {ds[0][5]};
            $ds6 = {ds[0][6]}; $ds7 = {ds[0][7]}; $ds8 = {ds[0][8]};
            $ds9 = {ds[0][9]}; $ds10 = {ds[0][10]}; $ds11 = {ds[0][11]};
            $ds12 = {ds[0][12]}; $ds13 = {ds[0][13]};

            Now I still got last problem with update that seem all correct but gives an error that has no sense-
            You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELLA GRUMELLINA 41 , phone = 0445526536 , office = Motoclub Bergamo' at line 7


            $update_table = 'events_rows'; // Table name
            $update_where = "event_row_ID = [glo_event_row_ID]"; // Where clause
            $update_fields =
            "event_subscriber_surname = $ds1,
            event_subscriber_name = $ds0 ,
            born_to = $ds3 ,
            born_date = $ds2 ,
            city = $ds7 ,
            zipcode = $ds8 ,
            address = $ds6 ,
            phone = $ds4 ,
            office = $ds11 ,
            office_code = $ds12 ,
            office_city = $ds13 ,
            license_nr = $ds10 ,
            fiscal_code = $ds9 ";

            // Update record
            $update_sql = 'UPDATE ' . $update_table
            . ' SET ' . $update_fields
            . ' WHERE ' . $update_where ;
            sc_exec_sql($update_sql);

            Comment


            • #7
              If a field or more than one of select is empty what happens then to UPDATE ?
              Does it need to make a test before of update like
              if (empty($ds1)) { $ds1='' ;}

              Comment


              • #8
                Originally posted by giovannino View Post
                $ds0 = {ds[0][0]}; $ds1 = {ds[0][1]}; $ds2 = {ds[0][2]};
                I have written that's wrong ...

                correct:
                $ds0 = {ds}[0][0]; $ds1 = {ds}[0][1]; $ds2 = {ds}[0][2];

                Originally posted by giovannino View Post
                OK, thanks. I've transformed all into vars.

                Needless ...

                UPDATE <table_name> SET <fieldname_1> = {ds}[0][1], <fieldname_2> = {ds}[0][2], ...
                Best regards: - Reinhard -

                I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

                Comment


                • #9
                  [SOLVED]
                  OK RHS,
                  many thanks !!

                  Comment

                  Working...
                  X