Problem

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]

<? session_start(); $DirName = ""; $UserEmail = htmlspecialchars($_GET["name"]); echo "Confirming account with email %...";

$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);
?>

[/php]

Okay, right after this line:

$FullCreateDir = $thisdir.’/’.$DirName;

Put this code:

[php]
echo $thisdir . “
” . $DirName . “
” . $FullCreateDir;
die (“folder name is above…”);
[/php]
And, see if the actual folder name is accurate. If not, fix it. If it is, make sure that the folder you are placing this folder it has write permissions.

Usually, you never allow write permission in the root directory. So, you normally have those in a second level folder. Let’s say it is “Folders”… Let’s say your NEW directory is going into “Folders”, “Folders” would need write permission. BUT, if the new directory is “Ernie/Alex”, then, it should work. BUT, if Folders/Ernie/ already exists, you can not put Ernie/Alex into Folders unless Ernie has write permissions… Might just be a simple issue as which folders have write permissions. Check your entries above and go from there…

Sponsor our Newsletter | Privacy Policy | Terms of Service