Announcement

Collapse
No announcement yet.

upload csv and import to database

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

  • #16
    That's the used function in my code snippet ;-)
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #17
      No, the second not ... ;-)
      Best regards: - Reinhard -

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

      Comment


      • #18
        Oh yes, even the second ;-)

        But they give a full code snippet like mine, but still the same function. But the export sample is nice too.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #19
          thats really cool thanks guys!

          Comment


          • #20
            hey guys hoping I can get some help on this.
            so have been trying to get this import working... have the form, upload and file opening, but failing on insert...
            table index key is auto inc and not inserted or included, but the error is:

            Error
            Undefined index: mbrDOB
            Undefined index: mbrNo
            Undefined index: mbrFname
            Undefined index: mbrLname

            The code is as follows:

            $cnt=0;
            $handle = fopen('C:/Program Files (x86)/NetMake/v7/wwwroot/scriptcase/file/doc/csvupload/'.{csv}, 'r');
            if(!$handle) die('Cannot open uploaded file.');

            if ($handle)
            {
            set_time_limit(0);

            //the top line is the field names
            $fields = fgetcsv($handle, 4096, ';');

            $empty='';

            // session variable - owner
            $clubID = [usr_club];

            //loop through one row at a time
            while (($data = fgetcsv($handle, 4096, ';')) !== FALSE)
            {
            $data = array_combine($fields, $data);

            if($data['mbrDOB']=='') {$data['mbrDOB']='01-01-1900';}

            $stm ='INSERT INTO mbr (mbrClubID,mbrNo,mbrFname,mbrLname,mbrDOB)
            values
            ('
            . '"'.$clubID.'",'
            . '"'.$data['mbrNo'].'",'
            . '"'.$data['mbrFname'].'",'
            . '"'.$data['mbrLname'].'",'
            . 'STR_TO_DATE("'.$data['mbrDOB'].'","%e-%m-%Y"),';

            sc_exec_sql($stm);

            $cnt++;
            }

            fclose($handle);
            }
            {reccnt}=$cnt;

            Comment


            • #21
              Guys???

              Help please! anybody....

              Comment


              • #22
                Test the generated sql statement. It looks to me as if the quotes are not used and the data is seen as a field name.
                Albert Drent
                aducom software netherlands
                scriptcase partner, reseller, support and (turn-key) development
                www.scriptcase.eu / www.scriptcase.nl

                Comment


                • #23
                  Originally posted by aducom View Post
                  Test the generated sql statement. It looks to me as if the quotes are not used and the data is seen as a field name.
                  thx will look into that

                  Comment


                  • #24
                    I am having problem in using load local data infile.. the error is:
                    "Error while accessing the database:
                    The used command is not allowed with this MySQL version"

                    anyone have encountered and solved this problem? thanks!

                    Comment


                    • #25
                      looks likes a compatibility problem. Please check your MySQL version and the version required for Scriptcase.
                      Albert Drent
                      aducom software netherlands
                      scriptcase partner, reseller, support and (turn-key) development
                      www.scriptcase.eu / www.scriptcase.nl

                      Comment

                      Working...
                      X