herghost Posted April 16, 2009 Share Posted April 16, 2009 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! Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted April 16, 2009 Share Posted April 16, 2009 You're missing a parenthesis if (!is_dir('../users/'.$userid) should be if (!is_dir('../users/'.$userid)) Quote Link to comment Share on other sites More sharing options...
herghost Posted April 16, 2009 Author Share Posted April 16, 2009 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? Quote Link to comment Share on other sites More sharing options...
herghost Posted April 16, 2009 Author Share Posted April 16, 2009 Ok through trial I can see this does not work and it does not create a directory, any pointers? Quote Link to comment Share on other sites More sharing options...
FaT3oYCG Posted April 16, 2009 Share Posted April 16, 2009 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()); Quote Link to comment Share on other sites More sharing options...
herghost Posted April 17, 2009 Author Share Posted April 17, 2009 Perfect! Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.