Jump to content

Mkdir Not Working?


localhost

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.
Link to comment
https://forums.phpfreaks.com/topic/13143-mkdir-not-working/
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.
Link to comment
https://forums.phpfreaks.com/topic/13143-mkdir-not-working/#findComment-50550
Share on other sites

Archived

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

×
×
  • Create New...

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.