Results 1 to 3 of 3

Thread: odbc_fetch_into Strange results

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    South Wales (UK)
    Posts
    83

    odbc_fetch_into Strange results

    The code below selects some data from an Access 2000 dbase, loops through and inserts the records into a temporary table. The correct number of records gets displayed but when it comes to inserting the records, the last record never gets added.

    Does anyone know why this is happening. Is my code right. Has anyone else tried a simular thing and got the correct results.

    I'm desperate so any help would be greatly appreciated.

    PHP Code:
    // List records in the current Hitlist table
        
    $query "SELECT Month, Year, ProjectName, HitlistID, TotalValue, Status FROM Hitlist ";
        
    $query $query."WHERE Month=$lMonth AND Year=$lYear AND UserID=$uUserID ";
        
    $result odbc_do ($con$query);

        while ( 
    odbc_fetch_into($result$row) != False )
        {
            
    $tHitlistID $row[3];
            
    $Status $row[5];

            
    // Columns
            
    $query1 "INSERT INTO Hit ";
            
    $query1 $query1." (Stat) ";
            
    // Values
            
    $query1 $query1." VALUES ( '$Status' ) ";
            
    odbc_do ($con$query1);

            echo 
    "<br><TR bgcolor=$Col>\n";
            echo 
    "<TD><A href=\"fd_form.php?HitlistID=".$row[3]."&action=edit&Key=".$Key."&lMonth=".$lMonth."&lYear=".$lYear."\">".$row[2]."</A></TD>\n";
            echo 
    "<TD>".number_format($row[4],2)."</TD>\n";
            echo 
    "<TD align=\"center\">$row[5]</TD>\n";
            echo 
    "</TR>\n";
        } 

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    so by looking at that query it looks like this

    // Columns
    $query1 = "INSERT INTO Hit (Stat) VALUES ( '$Status' ) ";
    odbc_do ($con, $query1);

    so just do it that way instead. see if it works? also do you get any kind of errors? try printing out the query and see if the values are there.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    South Wales (UK)
    Posts
    83
    Resolved, but it wasn't straight forward. I tried your code phpman but the same thing was happening, I even tried dumping the info into arrays and cycling through them after the while loop but again the same was happening.

    Eventually I found something on php.net about how odbc_pconnect causes problems when doing multiple updates one after another. So I changed my connection to odbc_connect and it worked perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width