DaMouse,

Toss in a few extra 'echo' and 'print_r($array)' statements regarding to
your number and you'll figure it out. That's what I just did. Make it work
before you make it pretty :) I fill my code with echo and print_r statements
so I know what the code further down is getting.

Here's the fixed code: (note I commented out some of your code - that's all
that I did)

<?php
if(!file_exists("./forum/"))
{
mkdir("./forum/", 0777);
}

if(@$_POST['dir'] == "")
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="dir" id="dir" />
<input type="submit" />
</form>
<?php
} else {
if(!file_exists("./forum/".$_POST['dir']."/"))
 {
  mkdir("./forum/".$_POST['dir']."/", 0777);
  echo "forum made";
 }
else
 {
  echo "forum already there";
 }
$forums = file("./forum/forums.xm");
for($f=0;$f<count($forums);$f++)
{
 $forums[$f] = explode(":",$forums[$f]);
 $forums[$f] = $forums[$f][0];
 settype($forums[$f],"integer");
}
//print_r($forums);
natsort($forums);
$forums = $forums[count($forums)-1];
/* This stuff makes the $forums var = 0, then ++'ing that makes it 1
$forums = explode(":","",$forums);
$forums = $forums[0];
settype($forums,"integer");
*/
$forums++;
if($fs=fopen("./forum/forums.xm","a"))
 {
  fwrite($fs,$forums.":".$_POST['dir']."\n");
  fclose($fs);
 }
}
?>

-Dash

-----Original Message-----
From: DaMouse [mailto:damouse@;ntlworld.com] 
Sent: Tuesday, November 12, 2002 8:02 PM
To: PHP - Win
Subject: [PHP-WIN] incrementation error


the following script is supposed to write a file and make a dir for a
corrosponding forum the only problem is it keeps coming out as
1:bbs
1:bbs2
1:bbs21
instead of
1:bbs
2:bbs2
3:bbs21
any ideas?
<?php
if(!file_exists("./forum/"))
{
mkdir("./forum/", 0777);
}

if($_POST['dir'] == "")
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="dir" id="dir" />
<input type="submit" />
</form>
<?php
} else {
if(!file_exists("./forum/".$_POST['dir']."/"))
 {
  mkdir("./forum/".$_POST['dir']."/", 0777);
  echo "forum made";
 }
else
 {
  echo "forum already there";
 }
$forums = file("./forum/forums.xm");
for($f=0;$f<count($forums);$f++)
{
 $forums[$f] = explode(":",$forums[$f]);
 $forums[$f] = $forums[$f][0];
 settype($forums[$f],"integer");
}
natsort($forums);
$forums = $forums[count($forums)-1];
$forums = explode(":","",$forums);
$forums = $forums[0];
settype($forums,"integer");
$forums++;
if($fs=fopen("./forum/forums.xm","a"))
 {
  fwrite($fs,++$forums.":".$_POST['dir']."\n");
  fclose($fs);
 }
}
?>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to