PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Dec 16, 2017 5:22 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem with copy script
PostPosted: Thu Sep 21, 2017 3:20 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
Hi,
I did a php script that would copy stuff via a JSON call.

Im having some troubles.. first it stops after 100 +- calls. I guess it's php that times out so I guess I have to do some javascript function that calls itself and the php script.. any suggestions?

Now to the really wierd part. I do a for $i to $i loop and writes the value of I to the database. When I look at the db it sometimes contain $i that is not in the $i range and it always write $i twice.. like

Syntax: [ Download ] [ Hide ]
1100
1100
1101
1101
1102
1102
1057 //*wtf??
1103
1103
1104
1104
1023 // ??????
1105
1105
..
.
EDIT: Now I noted i could get up to 7 of the same result???


 


First i tried to update it on the same id (greyed out) but it went completely bananas... since it sometimes add a random number i could for the interval below where it should end at 1199 get 1036, 1025, 1167... instead.

I looked at the db during runtime clicking refresh and it went like : 1101, 1134, 1102, 1103, 1167, 1104, 1126, 1105

so it was the same wierd random numbers showing up when i used the update function?

(Note this is while the script is running so no odd occurance due to php timeout)

Any idea why this is happening?

Syntax: [ Download ] [ Hide ]
for($i = 1100; $i < 1200; $i++){
 
    if ($stmt = $mysqli->prepare("SELECT
                GTIN
                FROM Dabas_GTIN where id = ?"
)){
                $stmt->bind_param('i', $i);
                $stmt->execute();
                $stmt->bind_result($CopyGTIN);
                $stmt->store_result();
                $stmt->fetch();
            }
    if(DabasCopy($CopyGTIN)){
        if($insert_stmt = $mysqli->prepare("UPDATE Dabas_GTIN SET copied = 'YES' WHERE id = ?")) {
                    $insert_stmt->bind_param('i',
                        $i);
                    $insert_stmt->execute();
                    }
    } else {die("Copy stopped at:".$i);}
    /*
        if($insert_stmt = $mysqli->prepare("UPDATE Copycount SET last = ? WHERE id = '1'")) {
                    $insert_stmt->bind_param('i',
                        $i);
                    $insert_stmt->execute();
                    }
    */


     if($insert_stmt = $mysqli->prepare("INSERT INTO Copycount (
                        last) VALUES (?)"
)) {
                        $insert_stmt->bind_param('i',
                            $i);
                        $insert_stmt->execute();
                    }
    sleep(2);
}
 


EDIT: I put id as key and autoincrease and renamed $i to something i know for sure i dont use anywhere else and i still get wierd results??

I do span 1200-1299


Syntax: [ Download ] [ Hide ]
up to 1229 id = last but  id=1230 i suddenly get last = 1200.
 then
1231-1230
1232-1201
1233-1231
1234-1202
1235-1232
1236-1203
1237-1233

ok so i guess you are starting to see a pattern here but at
1395-1233 *
1396-1293 l
1397-1205 x
1398-1264
1399-1234 *
1400-1294 l
1401-1206 x
1402-1265
1403-1235 *

so it forms some wierd pattern and after a while it adds a new loop to the pattern

like
a
a
a

a
b
a
b
a
b

a
b
c
a
b
c
a
b
c



 


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 3:55 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 172
I get the same result with a while loop
$ij=1300;
while($ij <1400){
code
$ij++;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group