Jump to content

PHP and ODBC and access database


otonomi

Recommended Posts

Hi all,

 

i have a problem with the following:

 

Whenever i try to insert more then 1024 records into an access database to insert query stops at 1024.

So if i get my result i see that only 1024 records are inserted.

 

I have no idea how this comes,

can anyone help me?

 

this is the code:

 

<?php

ob_start();

include 'connect/connect.php';

 

$iEmailsNotInserted=0;

$sEmailNotInserted="";

$new_key="";

$iAantal=0;

$listarray = array();

$txtBulkEmail = $_POST['txtBulkEmail'];

$txtList = $_POST['txtList'];

function createKey($amount)

                {

                $keyset = "abcdefghijklmnopqrstuvwxyzZ0123456789";

                $randkey = "";

                for ($i=0; $i<$amount; $i++)

                        {

                        $randkey .= substr($keyset, rand(0,strlen($keyset)-1), 1);

                        }

                return $randkey;

                }

//seperate emails and insert each email in database

$listarray= explode(";",$txtBulkEmail);

reset($listarray);

//remove duplicates from listarray

$clean_listarray = array_unique($listarray);

$aantal_in_clean_array = count($clean_listarray)-1;

echo "aantal: " . $aantal_in_clean_array;

 

//put all excisting subscribers in an array

$i=0;

$arrayAll = array();

$sqlALL ="SELECT ls_email FROM $txtList";

$queryALL = odbc_exec($conn, $sqlALL);

                while(odbc_fetch_row($queryALL))

                    {

                    $sfound_email = odbc_result($queryALL, "ls_email"); 

                    $trim_arrayAll[$i]= trim($sfound_email);

                    $i++;

                    }

$aantal_in_all_array=count($trim_arrayAll)-1;

 

for ($iFirstloop = 0; $iFirstloop<=$aantal_in_clean_array; $iFirstloop++)

    {

    //$matchgevonden telkens resetten

    $matchgevonden = "no";

    $trim_clean_listarray[$iFirstloop] =trim($clean_listarray[$iFirstloop]);

    //check if new mail allready exists in arrayall

    for ($iSecondLoop = 0; $iSecondLoop <= $aantal_in_all_array;$iSecondLoop++)

        {

        //echo "mailingevoegd: " . $trim_clean_listarray[$iFirstloop] .  " mail database: " . $trim_arrayAll[$iSecondLoop] . "<br>";

        if( $trim_clean_listarray[$iFirstloop]== $trim_arrayAll[$iSecondLoop])

                {

                $matchgevonden = "yes";

                $iEmailsNotInserted++;

                if ($iEmailsNotInserted<=20) 

                    {

                    $sEmailNotInserted=$sEmailNotInserted . $trim_clean_listarray[$iFirstloop] ."_";

                    }

                }

        }

    if ($matchgevonden!="yes")

        {

        //er is geen match gevonden 

        if ($trim_clean_listarray[$iFirstloop]!="")

                {

                $new_key = createKey(8) . "-" . createKey(4) . "-" . createKey(4) . "-" . createKey(4) . "-" . createKey(12);

                //de subscriber toevoegen

                $SQL_insert="INSERT INTO $txtList (ls_id,ls_email,ls_unsubscribed) VALUES ('$new_key','$trim_clean_listarray[$iFirstloop]','0')";

                echo $SQL_insert . "<br>";

                $resultupdate= odbc_exec($conn,$SQL_insert);

                }

        }

    }

odbc_close($conn);

//header("Location:index.php?list=" . $txtList . "&action=insertall&notinserted=$iEmailsNotInserted&notinsertedm=$sEmailNotInserted");

 

ob_end_flush();

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.