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
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?

Link to comment
Share on other sites

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());

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.