Hi,
I’ve been looking at this for a while and can’t work out what I’ve done wrong and why it isn’t working. It isn’t creating either the folder or the file. I have checked permissions.
[php]
$con = mysql_connect(“localhost”,“Jordan”,"");
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“Users”, $con);
mysql_query(“UPDATE Accounts SET Confirmed=‘True’ WHERE Email=’$UserEmail’”);
mysql_close($con);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“Users”, $con);
$result = mysql_query(“SELECT * FROM Accounts WHERE Email=’$UserEmail’”);
while($row = mysql_fetch_array($result))
{
$DirName = $row[‘URLSuffix’];
//$DirName = $row[‘URLSuffix’];
//
/* wherever this particular script will be installed, I want to create a subfolder /
/ Step 1. I need to know the absolute path to where I am now, ie where this script is running from…*/
$thisdir = getcwd();
$FullCreateDir = $thisdir.’/’.$DirName;
/* Step 2. From this folder, I want to create a subfolder called “myfiles”. Also, I want to try and make this folder world-writable (CHMOD 0777). Tell me if success or failure… */
if(mkdir($FullCreateDir , 0777))
{
echo “Directory has been created successfully…”;
}
else
{
echo “Failed to create directory…”;
}
$ourFileName = $FullCreateDir . “/new.php”;
$ourFileHandle = fopen($ourFileName, ‘w’) or die(“can’t open file”);
fclose($ourFileHandle);
$myFile = $FullCreateDir . “/new.php”;
$fh = fopen($myFile, ‘w’) or die(“can’t open file”);
//HTML Code for new file
$stringData = "
Welcome :)
"; fwrite($fh, $stringData);
fclose($fh);
}
mysql_close($con);
?>