Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"Because of this forum, I continue to WOW! my clients!"

Geography

Where in the world do Tek-Tips members come from?
max2474 (Programmer)
15 May 12 18:17
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 :

CODE --> 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 :

CODE --> 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 :

Quote (output)

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:

Quote (output)

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
giving no value to "test", assumably the failed write.
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.
max2474 (Programmer)
16 May 12 7:33
Got some help on the original thread which solved this. Many thanks for looking :)

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close