Jump to content

Archived

This topic is now archived and is closed to further replies.

localhost

Mkdir Not Working?

Recommended Posts

[code]$query = "INSERT INTO users (`username`, `email`, `password`, `joindate`, `ipaddress`, `auth`, `dir`) VALUES ('$username', '$email', '$enc_password', '$joindate', '$ipaddress', '$auth', '$num')";
$result = mysql_query($query) or die('Could not insert user details into database.');

}
}

if($result) {

$queryS = "SELECT * FROM users";
$resultS = mysql_query($queryS) or die(mysql_error());

$fetch = mysql_fetch_array($resultS) or die(mysql_error());
$userdir = $fetch['dir'];

/* NOTE, BACKSLASHES MUST BE USED WITH WINDOWS, IF ON LINUX OR UNIX SERVER REPLACE \ WITH /'S IN THE NEXT LINE */
mkdir("files\$userdir\$username", 0777);
}[/code]

i made it so a random code is generated numbers only, is then inserted into the database under that users row, i am trying to make it so upon registration it takes that 6 digit code and makes the folder under files\.
it is not working, although the 6 digit random number does get generated and inserted into the db.

Share this post


Link to post
Share on other sites
With windows use two \\ like so:
[i]mkdir("files\\$userdir\\$username", 0777);[/i]
Currently PHP is escaping the $ sign on your variables so it creating folder called 'files$userdir$username' it is not parsing the variables. Now with the double backslahes PHP will not escape the $ sign.

Also chnaging the CHMOD settings to 0777 is completly usedless on Windows as it doesnt use CHMOD.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.