lupld Posted August 15, 2007 Share Posted August 15, 2007 ok.. can someone just simply tell me what keeps this from working... it's something with the if statements.. but I don't know what for the life of me... are if statements disabled in for, while, and each loops? <?php $rnum = 10001; //remember that these are incremented, so start out 1 less... $lup = 20000; $ldown = 0; $lwest = 0; $least = 10001; for( $rnum = 10001; $rnum <20001); $rnum++ { if($rnum >= 20001) { die("Completed, you may now exit to the room.php page"); } $lup++ $ldown++ $lwest++ $least++ if($rnum == "10101") { $lnorth = 10001; }else{} if($rnum >= 10102) { $lnorth++ }else{} if($rnum <= 19900) { $lsouth++ }else{ $lsouth = ""; } //since nobody seems to get this, it sets all of these rooms blank either on the left link or right link... and then on the page that displays this, I use an if statement to echo a link back if it's filled, and then just the words "move left" or "move right" if blanks... if($rnum == "10100" || $rnum == "10200" || $rnum == "10300" || $rnum == "10400" || $rnum == "10500" || $rnum == "10600" || $rnum == "10700" || $rnum == "10800" || $rnum == "10900" || $rnum == "101000" || $rnum == "11100" || $rnum == "11200" || $rnum == "11300" || $rnum == "11400" || $rnum == "11500" || $rnum == "11600" || $rnum == "11700" || $rnum == "11800" || $rnum == "11900" || $rnum == "12000" || $rnum == "12100" || $rnum == "12200" || $rnum == "12300" || $rnum == "12400" || $rnum == "12500" || $rnum == "12600" || $rnum == "12700" || $rnum == "12800" || $rnum == "12900" || $rnum == "13000" || $rnum == "13100" || $rnum == "13200" || $rnum == "13300" || $rnum == "13400" || $rnum == "13500" || $rnum == "13600" || $rnum == "13700" || $rnum == "13800" || $rnum == "13900" || $rnum == "14000" || $rnum == "14100" || $rnum == "14200" || $rnum == "14300" || $rnum == "14400" || $rnum == "14500" || $rnum == "14600" || $rnum == "14700" || $rnum == "14800" || $rnum == "14900" || $rnum == "15000" || $rnum == "15100" || $rnum == "15200" || $rnum == "15300" || $rnum == "15400" || $rnum == "15500" || $rnum == "15600" || $rnum == "15700" || $rnum == "15800" || $rnum == "15900" || $rnum == "16000" || $rnum == "16100" || $rnum == "16200" || $rnum == "16300" || $rnum == "16400" || $rnum == "16500" || $rnum == "16600" || $rnum == "16700" || $rnum == "16800" || $rnum == "16900" || $rnum == "17000" || $rnum == "17100" || $rnum == "17200" || $rnum == "17300" || $rnum == "17400" || $rnum == "17500" || $rnum == "17600" || $rnum == "17700" || $rnum == "17800" || $rnum == "17900" || $rnum == "18000" || $rnum == "18100" || $rnum == "18200" || $rnum == "18300" || $rnum == "18400" || $rnum == "18500" || $rnum == "18600" || $rnum == "18700" || $rnum == "18800" || $rnum == "18900" || $rnum == "19000" || $rnum == "19100" || $rnum == "19200" || $rnum == "19300" || $rnum == "19400" || $rnum == "19500" || $rnum == "19600" || $rnum == "19700" || $rnum == "19800" || $rnum == "19900" || $rnum == "20000") { $tempvar = $least; $least = ""; } if($rnum == "10001" || $rnum == "10101" || $rnum == "10201" || $rnum == "10301" || $rnum == "10401" || $rnum == "10501" || $rnum == "10601" || $rnum == "10701" || $rnum == "10801" || $rnum == "10901" || $rnum == "11001" || $rnum == "11101" || $rnum == "11201" || $rnum == "11301" || $rnum == "11401" || $rnum == "11501" || $rnum == "11601" || $rnum == "11701" || $rnum == "11801" || $rnum == "11901" || $rnum == "12001" || $rnum == "12101" || $rnum == "12201" || $rnum == "12301" || $rnum == "12401" || $rnum == "12501" || $rnum == "21601" || $rnum == "12701" || $rnum == "12801" || $rnum == "12901" || $rnum == "13001" || $rnum == "13101" || $rnum == "13201" || $rnum == "13301" || $rnum == "13401" || $rnum == "13501" || $rnum == "13601" || $rnum == "13701" || $rnum == "13801" || $rnum == "13901" || $rnum == "14001" || $rnum == "14101" || $rnum == "14201" || $rnum == "14301" || $rnum == "14401" || $rnum == "14501" || $rnum == "14601" || $rnum == "14701" || $rnum == "14801" || $rnum == "14901" || $rnum == "15001" || $rnum == "15101" || $rnum == "15201" || $rnum == "15301" || $rnum == "15401" || $rnum == "15501" || $rnum == "15601" || $rnum == "15701" || $rnum == "15801" || $rnum == "15901" || $rnum == "16001" || $rnum == "16101" || $rnum == "16201" || $rnum == "16301" || $rnum == "16401" || $rnum == "16501" || $rnum == "16601" || $rnum == "16701" || $rnum == "16801" || $rnum == "16901" || $rnum == "17001" || $rnum == "17101" || $rnum == "17201" || $rnum == "17301" || $rnum == "17401" || $rnum == "17501" || $rnum == "17601" || $rnum == "17701" || $rnum == "17801" || $rnum == "17901" || $rnum == "18001" || $rnum == "18101" || $rnum == "18201" || $rnum == "18301" || $rnum == "18401" || $rnum == "18501" || $rnum == "18601" || $rnum == "18701" || $rnum == "18801" || $rnum == "18901" || $rnum == "19001" || $rnum == "19101" || $rnum == "19201" || $rnum == "19301" || $rnum == "19401" || $rnum == "19501" || $rnum == "19601" || $rnum == "19701" || $rnum == "19801" || $rnum == "19901") { $tempvar2 = $lwest; $lwest = ""; } $permis = "0"; mysql_query("INSERT INTO `rooms` (rnum, lup, ldown, lwest, least, lnorth, lsouth, rcontents, rname, permis) VALUES ('$rnum','$lup','$ldown','$lwest','$least','$lnorth','$lsouth','$rcontents','$rname','permis');") or die(mysql_error()) if(!$least) { $least = $tempvar } if(!$west) { $lwest = $tempvar2 } } ?> it's long.. but if I get it to work, it will save me 10,000 database entries... current error: Parse error: syntax error, unexpected ')', expecting ';' in /home/arcane/public_html/roomcreator.php on line 10 (not line 10 here.. this is everything but the database connection though..) Quote Link to comment https://forums.phpfreaks.com/topic/65003-solved-php-to-fill-a-database-loop-maybe/ Share on other sites More sharing options...
NArc0t1c Posted August 15, 2007 Share Posted August 15, 2007 Try: <?php $rnum = 10001; //remember that these are incremented, so start out 1 less... $lup = 20000; $ldown = 0; $lwest = 0; $least = 10001; for($rnum = 10001;$rnum<20001;$rnum++) { if($rnum >= 20001) { die("Completed, you may now exit to the room.php page"); } $lup++; $ldown++; $lwest++; $least++; if($rnum == "10101") { $lnorth = 10001; } elseif($rnum >= 10102) { $lnorth++; } elseif($rnum <= 19900) { $lsouth++; } else{ $lsouth = ""; } //since nobody seems to get this, it sets all of these rooms blank either on the left link or right link... and then on the page that displays this, I use an if statement to echo a link back if it's filled, and then just the words "move left" or "move right" if blanks... if($rnum == "10100" || $rnum == "10200" || $rnum == "10300" || $rnum == "10400" || $rnum == "10500" || $rnum == "10600" || $rnum == "10700" || $rnum == "10800" || $rnum == "10900" || $rnum == "101000" || $rnum == "11100" || $rnum == "11200" || $rnum == "11300" || $rnum == "11400" || $rnum == "11500" || $rnum == "11600" || $rnum == "11700" || $rnum == "11800" || $rnum == "11900" || $rnum == "12000" || $rnum == "12100" || $rnum == "12200" || $rnum == "12300" || $rnum == "12400" || $rnum == "12500" || $rnum == "12600" || $rnum == "12700" || $rnum == "12800" || $rnum == "12900" || $rnum == "13000" || $rnum == "13100" || $rnum == "13200" || $rnum == "13300" || $rnum == "13400" || $rnum == "13500" || $rnum == "13600" || $rnum == "13700" || $rnum == "13800" || $rnum == "13900" || $rnum == "14000" || $rnum == "14100" || $rnum == "14200" || $rnum == "14300" || $rnum == "14400" || $rnum == "14500" || $rnum == "14600" || $rnum == "14700" || $rnum == "14800" || $rnum == "14900" || $rnum == "15000" || $rnum == "15100" || $rnum == "15200" || $rnum == "15300" || $rnum == "15400" || $rnum == "15500" || $rnum == "15600" || $rnum == "15700" || $rnum == "15800" || $rnum == "15900" || $rnum == "16000" || $rnum == "16100" || $rnum == "16200" || $rnum == "16300" || $rnum == "16400" || $rnum == "16500" || $rnum == "16600" || $rnum == "16700" || $rnum == "16800" || $rnum == "16900" || $rnum == "17000" || $rnum == "17100" || $rnum == "17200" || $rnum == "17300" || $rnum == "17400" || $rnum == "17500" || $rnum == "17600" || $rnum == "17700" || $rnum == "17800" || $rnum == "17900" || $rnum == "18000" || $rnum == "18100" || $rnum == "18200" || $rnum == "18300" || $rnum == "18400" || $rnum == "18500" || $rnum == "18600" || $rnum == "18700" || $rnum == "18800" || $rnum == "18900" || $rnum == "19000" || $rnum == "19100" || $rnum == "19200" || $rnum == "19300" || $rnum == "19400" || $rnum == "19500" || $rnum == "19600" || $rnum == "19700" || $rnum == "19800" || $rnum == "19900" || $rnum == "20000") { $tempvar = $least; $least = ""; } if($rnum == "10001" || $rnum == "10101" || $rnum == "10201" || $rnum == "10301" || $rnum == "10401" || $rnum == "10501" || $rnum == "10601" || $rnum == "10701" || $rnum == "10801" || $rnum == "10901" || $rnum == "11001" || $rnum == "11101" || $rnum == "11201" || $rnum == "11301" || $rnum == "11401" || $rnum == "11501" || $rnum == "11601" || $rnum == "11701" || $rnum == "11801" || $rnum == "11901" || $rnum == "12001" || $rnum == "12101" || $rnum == "12201" || $rnum == "12301" || $rnum == "12401" || $rnum == "12501" || $rnum == "21601" || $rnum == "12701" || $rnum == "12801" || $rnum == "12901" || $rnum == "13001" || $rnum == "13101" || $rnum == "13201" || $rnum == "13301" || $rnum == "13401" || $rnum == "13501" || $rnum == "13601" || $rnum == "13701" || $rnum == "13801" || $rnum == "13901" || $rnum == "14001" || $rnum == "14101" || $rnum == "14201" || $rnum == "14301" || $rnum == "14401" || $rnum == "14501" || $rnum == "14601" || $rnum == "14701" || $rnum == "14801" || $rnum == "14901" || $rnum == "15001" || $rnum == "15101" || $rnum == "15201" || $rnum == "15301" || $rnum == "15401" || $rnum == "15501" || $rnum == "15601" || $rnum == "15701" || $rnum == "15801" || $rnum == "15901" || $rnum == "16001" || $rnum == "16101" || $rnum == "16201" || $rnum == "16301" || $rnum == "16401" || $rnum == "16501" || $rnum == "16601" || $rnum == "16701" || $rnum == "16801" || $rnum == "16901" || $rnum == "17001" || $rnum == "17101" || $rnum == "17201" || $rnum == "17301" || $rnum == "17401" || $rnum == "17501" || $rnum == "17601" || $rnum == "17701" || $rnum == "17801" || $rnum == "17901" || $rnum == "18001" || $rnum == "18101" || $rnum == "18201" || $rnum == "18301" || $rnum == "18401" || $rnum == "18501" || $rnum == "18601" || $rnum == "18701" || $rnum == "18801" || $rnum == "18901" || $rnum == "19001" || $rnum == "19101" || $rnum == "19201" || $rnum == "19301" || $rnum == "19401" || $rnum == "19501" || $rnum == "19601" || $rnum == "19701" || $rnum == "19801" || $rnum == "19901") { $tempvar2 = $lwest; $lwest = ""; } $permis = "0"; mysql_query("INSERT INTO `rooms` (rnum, lup, ldown, lwest, least, lnorth, lsouth, rcontents, rname, permis) VALUES ('$rnum','$lup','$ldown','$lwest','$least','$lnorth','$lsouth','$rcontents','$rname','permis');") or die(mysql_error()); if(!$least) { $least = $tempvar; } if(!$west) { $lwest = $tempvar2; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65003-solved-php-to-fill-a-database-loop-maybe/#findComment-324417 Share on other sites More sharing options...
lupld Posted August 15, 2007 Author Share Posted August 15, 2007 everything submitted, but west didn't work right.. it incremented once every 100 entries... other than that, thanks tons... Quote Link to comment https://forums.phpfreaks.com/topic/65003-solved-php-to-fill-a-database-loop-maybe/#findComment-324422 Share on other sites More sharing options...
MrBillybob Posted August 15, 2007 Share Posted August 15, 2007 last if said !$west instead of !$lwest <?php $rnum = 10001; //remember that these are incremented, so start out 1 less... $lup = 20000; $ldown = 0; $lwest = 0; $least = 10001; for($rnum = 10001;$rnum<20001;$rnum++) { if($rnum >= 20001) { die("Completed, you may now exit to the room.php page"); } $lup++; $ldown++; $lwest++; $least++; if($rnum == "10101") { $lnorth = 10001; } elseif($rnum >= 10102) { $lnorth++; } elseif($rnum <= 19900) { $lsouth++; } else{ $lsouth = ""; } //since nobody seems to get this, it sets all of these rooms blank either on the left link or right link... and then on the page that displays this, I use an if statement to echo a link back if it's filled, and then just the words "move left" or "move right" if blanks... if($rnum == "10100" || $rnum == "10200" || $rnum == "10300" || $rnum == "10400" || $rnum == "10500" || $rnum == "10600" || $rnum == "10700" || $rnum == "10800" || $rnum == "10900" || $rnum == "101000" || $rnum == "11100" || $rnum == "11200" || $rnum == "11300" || $rnum == "11400" || $rnum == "11500" || $rnum == "11600" || $rnum == "11700" || $rnum == "11800" || $rnum == "11900" || $rnum == "12000" || $rnum == "12100" || $rnum == "12200" || $rnum == "12300" || $rnum == "12400" || $rnum == "12500" || $rnum == "12600" || $rnum == "12700" || $rnum == "12800" || $rnum == "12900" || $rnum == "13000" || $rnum == "13100" || $rnum == "13200" || $rnum == "13300" || $rnum == "13400" || $rnum == "13500" || $rnum == "13600" || $rnum == "13700" || $rnum == "13800" || $rnum == "13900" || $rnum == "14000" || $rnum == "14100" || $rnum == "14200" || $rnum == "14300" || $rnum == "14400" || $rnum == "14500" || $rnum == "14600" || $rnum == "14700" || $rnum == "14800" || $rnum == "14900" || $rnum == "15000" || $rnum == "15100" || $rnum == "15200" || $rnum == "15300" || $rnum == "15400" || $rnum == "15500" || $rnum == "15600" || $rnum == "15700" || $rnum == "15800" || $rnum == "15900" || $rnum == "16000" || $rnum == "16100" || $rnum == "16200" || $rnum == "16300" || $rnum == "16400" || $rnum == "16500" || $rnum == "16600" || $rnum == "16700" || $rnum == "16800" || $rnum == "16900" || $rnum == "17000" || $rnum == "17100" || $rnum == "17200" || $rnum == "17300" || $rnum == "17400" || $rnum == "17500" || $rnum == "17600" || $rnum == "17700" || $rnum == "17800" || $rnum == "17900" || $rnum == "18000" || $rnum == "18100" || $rnum == "18200" || $rnum == "18300" || $rnum == "18400" || $rnum == "18500" || $rnum == "18600" || $rnum == "18700" || $rnum == "18800" || $rnum == "18900" || $rnum == "19000" || $rnum == "19100" || $rnum == "19200" || $rnum == "19300" || $rnum == "19400" || $rnum == "19500" || $rnum == "19600" || $rnum == "19700" || $rnum == "19800" || $rnum == "19900" || $rnum == "20000") { $tempvar = $least; $least = ""; } if($rnum == "10001" || $rnum == "10101" || $rnum == "10201" || $rnum == "10301" || $rnum == "10401" || $rnum == "10501" || $rnum == "10601" || $rnum == "10701" || $rnum == "10801" || $rnum == "10901" || $rnum == "11001" || $rnum == "11101" || $rnum == "11201" || $rnum == "11301" || $rnum == "11401" || $rnum == "11501" || $rnum == "11601" || $rnum == "11701" || $rnum == "11801" || $rnum == "11901" || $rnum == "12001" || $rnum == "12101" || $rnum == "12201" || $rnum == "12301" || $rnum == "12401" || $rnum == "12501" || $rnum == "21601" || $rnum == "12701" || $rnum == "12801" || $rnum == "12901" || $rnum == "13001" || $rnum == "13101" || $rnum == "13201" || $rnum == "13301" || $rnum == "13401" || $rnum == "13501" || $rnum == "13601" || $rnum == "13701" || $rnum == "13801" || $rnum == "13901" || $rnum == "14001" || $rnum == "14101" || $rnum == "14201" || $rnum == "14301" || $rnum == "14401" || $rnum == "14501" || $rnum == "14601" || $rnum == "14701" || $rnum == "14801" || $rnum == "14901" || $rnum == "15001" || $rnum == "15101" || $rnum == "15201" || $rnum == "15301" || $rnum == "15401" || $rnum == "15501" || $rnum == "15601" || $rnum == "15701" || $rnum == "15801" || $rnum == "15901" || $rnum == "16001" || $rnum == "16101" || $rnum == "16201" || $rnum == "16301" || $rnum == "16401" || $rnum == "16501" || $rnum == "16601" || $rnum == "16701" || $rnum == "16801" || $rnum == "16901" || $rnum == "17001" || $rnum == "17101" || $rnum == "17201" || $rnum == "17301" || $rnum == "17401" || $rnum == "17501" || $rnum == "17601" || $rnum == "17701" || $rnum == "17801" || $rnum == "17901" || $rnum == "18001" || $rnum == "18101" || $rnum == "18201" || $rnum == "18301" || $rnum == "18401" || $rnum == "18501" || $rnum == "18601" || $rnum == "18701" || $rnum == "18801" || $rnum == "18901" || $rnum == "19001" || $rnum == "19101" || $rnum == "19201" || $rnum == "19301" || $rnum == "19401" || $rnum == "19501" || $rnum == "19601" || $rnum == "19701" || $rnum == "19801" || $rnum == "19901") { $tempvar2 = $lwest; $lwest = ""; } $permis = "0"; mysql_query("INSERT INTO `rooms` (rnum, lup, ldown, lwest, least, lnorth, lsouth, rcontents, rname, permis) VALUES ('$rnum','$lup','$ldown','$lwest','$least','$lnorth','$lsouth','$rcontents','$rname','permis');") or die(mysql_error()); if(!$least) { $least = $tempvar; } if(!$lwest) { $lwest = $tempvar2; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65003-solved-php-to-fill-a-database-loop-maybe/#findComment-324424 Share on other sites More sharing options...
lupld Posted August 15, 2007 Author Share Posted August 15, 2007 I read right over that too.. I kept wanting to change other stuff, but I knew if $least worked there wasn't anything or much wrong with the rest of it... thanks tons... I used a rather made up way with session variables and headers to simulate the loop *edit* before this *edit*.. took and hour plus to finish... (hence it started at 10,000 instead of 1) I had another post and nobody could figure out what I was trying to do... Quote Link to comment https://forums.phpfreaks.com/topic/65003-solved-php-to-fill-a-database-loop-maybe/#findComment-324427 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.