|
-
May 15th, 2003, 06:49 AM
#1
Thread Starter
Lively Member
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";
}
-
May 15th, 2003, 11:29 AM
#2
Frenzied Member
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.
-
May 19th, 2003, 03:22 AM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|