Jump to content

[SOLVED] Further Mkdir Help


herghost

Recommended Posts

Hi all,

 

 

I have the following code:

 

<?php
session_start();
include('include/database.php');
include('include/auth.php');

$userid = $_SESSION['SESS_USERID'];


$query = "SELECT * FROM user WHERE userid = $userid";

			$result = mysql_query($query) or die(mysql_error());

			if ($result)
{
while ($r = mysql_fetch_array($result))
{
   
$userid = $r["userid"];

} 
}
if (!is_dir('../users/'.$userid)

{
mkdir('../users/'.$userid);
} 

?>

 

Which is just meant to check if a directory exist for a user and if not create it, however I am getting a parse error on line 24 which is :

 

line23:(empty)
line24:{
line25: mkdir('../users/'.$userid);

 

this is the 1st time I have ever looked at mkdir so it may be something fundementaly wrong that is not a simple fix!

Link to comment
https://forums.phpfreaks.com/topic/154427-solved-further-mkdir-help/
Share on other sites

you know when you feel like an idiot ........

 

 

Thanks :)

 

However, the script I have got, I have a feeling it is trying to create a directory if it does exist? Should it be that it creates if it doesnt?! The only reason I have come to this conclusion is because I have had this error before when it does exist:

 

Warning: mkdir() [function.mkdir]: No such file or directory in bandpic.php on line 25

 

I am guessing I need something like

 

if (!is_dir('../users/'.$userid))

{
//move onto a form
} 

else 
{
mkdir('../users/'.$userid);
}

 

Am I correct?

actually scrap that, erm the code looks right hang on

 

maybe try this

 

<?php
    session_start();
    include('include/database.php');
    include('include/auth.php');

    $userid = $_SESSION['SESS_USERID'];
    $sql = "SELECT * FROM user WHERE userid = $userid";
    $result = mysql_query($sql) or die(mysql_error());

    if ($result)
    {
        while ($row = mysql_fetch_array($result))
        {
            $userid = $row["userid"];
            if (is_dir('../users/'.$userid) == FALSE)
            {
                mkdir('../users/'.$userid);
            }
        } 
    }
?>

 

p.s. if that doesnt work add this line to the bottom

echo(getcwd());

 

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.