CASE loops not working for me.
Posted: Fri Nov 10, 2006 6:42 pm
My code all works so far, but its suppost to make files with each of the case names, but doesn't, just 6 all called attack atm. Any ideas?
Code: Select all
<?php
$username = $_GET["username"];
$password = $_GET["password"];
$filename = "$username.php";
if (!$handle = fopen($filename, 'a')) {
die ("Error while connecting, please try again.");
} else {
if (fwrite($handle, $password) === FALSE){
die("Error while writing.");
}
}
echo "$username's account has been created";
fclose($handle);
$loop=1;
for ( $counter = 1; $counter <= 6; $counter ++ ) {
$loop == $loop+1;
switch($loop){
case 1: $stat = "Attack";
case 2: $stat = "Cooking";
case 3: $stat = "Crafting";
case 4: $stat = "Defence";
case 5: $stat = "Firemaking";
case 6: $stat = "Fishing";
}
if (!$handle = fopen("$username$stat.php", 'a')) {
die ("Error while connecting, please try again.");
} else {
if (fwrite($handle, '<title>1</title>') === FALSE){
die("Error while writing.");
}
}
echo "<br>$stat level set at 1.";
fclose($handle);
}
?>