First, please see here as I originally thought this to be a php issue.
Am almost at the pulling hair out stage...lol. I have 5 dynamically chosen tables to write to depending on user input.
If plan1 is chosen, all info is updated in the database perfectly. If any other plan number is chosen the query fails.
To try and find the error, I have changed the query to this :
so with the whole loop, we have this :
comparing outputs - choosing plan1 gives :
and choosing plan2 gives:
Please note, the differing values 3 and 8 are just different numbers to write to the table.
I can see no difference that would explain why plan1 works and plan2 etc fail.
Any tips would be greatly appreciated.
Am almost at the pulling hair out stage...lol. I have 5 dynamically chosen tables to write to depending on user input.
If plan1 is chosen, all info is updated in the database perfectly. If any other plan number is chosen the query fails.
To try and find the error, I have changed the query to this :
PHP:
$test= mysql_query("UPDATE $newplan SET $lnt = '$ltu', $lnn = '$lnu', plantot = '$ptu', plannew = '$pnu'
WHERE userid = '$w' LIMIT 1");
echo "newplan is ".$newplan.". lnt is ".$lnt.". ltu is ".$ltu.". lnn is ".$lnn.". lnu is ".$lnu.". plantot is ".plantot.". ptu is ".$ptu.". plannew is ".$plannew.". pnu is ".$pnu.". w is ".$w;
echo "<br /> testt is ".$test."<br />";
so with the whole loop, we have this :
PHP:
$newplan="plan".$_SESSION[plan];
$g=1;
while ($g <= 9)
{
$w=$_SESSION[refs][$g-1];
$lnt="lvl".$g."tot";
$lnn="lvl".$g."new";
$ltu=($_SESSION[rlvltot][$g-1])+1;
$lnu=($_SESSION[rlvlnew][$g-1])+1;
$ptu=($_SESSION[rplantot][$g-1])+1;
$pnu=($_SESSION[rplannew][$g-1])+1;
$test= mysql_query("UPDATE $newplan SET $lnt = '$ltu', $lnn = '$lnu', plantot = '$ptu', plannew = '$pnu'
WHERE userid = '$w' LIMIT 1");
echo "newplan is ".$newplan.". lnt is ".$lnt.". ltu is ".$ltu.". lnn is ".$lnn.". lnu is ".$lnu.". plantot is ".plantot.". ptu is ".$ptu.". plannew is ".$plannew.". pnu is ".$pnu.". w is ".$w;
echo "<br /> test is ".$test."<br />";
$g++;
}
comparing outputs - choosing plan1 gives :
output said:newplan is plan1. lnt is lvl1tot. ltu is 8. lnn is lvl1new. lnu is 8. plantot is plantot. ptu is 8. plannew is . pnu is 8. w is 11
test is 1
newplan is plan1. lnt is lvl2tot. ltu is 8. lnn is lvl2new. lnu is 8. plantot is plantot. ptu is 8. plannew is . pnu is 8. w is 10
test is 1
newplan is plan1. lnt is lvl3tot. ltu is 8. lnn is lvl3new. lnu is 8. plantot is plantot. ptu is 8. plannew is . pnu is 8. w is 7
test is 1
etc
etc
and choosing plan2 gives:
giving no value to "test", assumably the failed write.output said:newplan is plan2. lnt is lvl1tot. ltu is 3. lnn is lvl1new. lnu is 3. plantot is plantot. ptu is 1. plannew is . pnu is 3. w is 11
test is
newplan is plan2. lnt is lvl2tot. ltu is 3. lnn is lvl2new. lnu is 3. plantot is plantot. ptu is 1. plannew is . pnu is 3. w is 10
test is
newplan is plan2. lnt is lvl3tot. ltu is 3. lnn is lvl3new. lnu is 3. plantot is plantot. ptu is 1. plannew is . pnu is 3. w is 7
test is
etc
etc
Please note, the differing values 3 and 8 are just different numbers to write to the table.
I can see no difference that would explain why plan1 works and plan2 etc fail.
Any tips would be greatly appreciated.