Jump to content

Data loss


brianab

Recommended Posts

Using PHP, I set up two for loops one inside the other with a database read statement in between. This works fine for small loops but on larger loops the data just dissappears. The scipt completes without error.

 

<?php

$END=174;

$SUBJECTLIST=array("aa","bb","cc"); //Total OF 40 ELEMENTS

for ($x=0; $x < $END; ++$x)

{

for ($c=0; $c < 40; ++$c)

{

 

// OPEN DATABASE

$conn=odbc_connect('xxx','','');

if (!$conn)

  {exit("Database Connection Failed: " . $conn);}

 

$sql="SELECT * FROM $DATABASE WHERE a2='$Identity[$x]' and a11='$SUBJECTLIST[$c]'";

 

$rs=odbc_exec($conn,$sql);

if (!$rs)

  {exit("Error in $DATABASE SQL");}

 

while (odbc_fetch_row($rs))

{

 

  $NAME[$x]=odbc_result($rs,"a2");

  $Information[$x]=odbc_result($rs,"a11");

 

// Twenty other odbc_result statements

 

}// End of WHILE

 

odbc_free_result($rs);

odbc_close($conn);

 

 

// Printing out the values, the data suddenly stops. Each time varying by a couple of

// rows.

 

}

}

?>

 

Why does this occur ?

Is there a better way of coding ?

Any help please..

 

Regards,

Brian

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.