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
https://forums.phpfreaks.com/topic/175932-php-and-odbc-and-access-database/
Share on other sites

what script ever could warrant inserting 1024 RECORDS in 1 query? :S

 

or do you mean you can't loop and insert more than 1024 records? in this case it is more likely that your php script is timing out

 

set_time_limit

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.