Jump to content

Recommended Posts

Okay what i'm trying to do is make a folder named variable $username in a certain section of the site

[code]
function create($md5=0){

if(!$md5)
$pline = "md5(':password:')";
else
$pline = "':password:'";

$sql_query="INSERT INTO members (email,username,password,fname,lname)
VALUES (':email:',':username:',".$pline.",':fname:',':lname:')";

$mem_id = $this->insert($sql_query);

$sql_query="INSERT INTO members_settings (mem_id) VALUES (".$mem_id.")";
$this->execute($sql_query);

$sql_query="INSERT INTO profile_access (mem_id) VALUES (".$mem_id.")";
$this->execute($sql_query);

if($GLOBALS["settings"]["track_profiles"])
$approved = 0;
else
$approved = 1;

        $sql_query = "INSERT INTO profiles(mem_id,joined,updated,last_visit,last_click,photo,photo_med,photo_small,approved,folder)
VALUES (".$mem_id.",".time().",".time().",".time().",".time().",'awaiting.gif','awaiting.gif','awaiting_small.gif ','".$approved."',':username:')";

        $username = ':username:';

        $this->execute($sql_query);

$sql_query="INSERT INTO network(mem_id,friends,friends_of_friends)
VALUES(".$mem_id.",',',',')";
$this->execute($sql_query);

$this->create_profile($mem_id);

load_3rdparty("register",$this->values);

return $mem_id;

}

function create_profile($username){

include(DOC_ROOT."/themes/".$GLOBALS["THEME"]."/modules/profiles.inc.php");
if(!file_exists($profiles["path"]."/".$username))
mkdir($profiles["path"]."/".$username,PERMISSIONS);

copy($profiles["path"]."/default/index.php",$profiles["path"]."/".$username."/index.php");
chmod($profiles["path"]."/".$username."/index.php",PERMISSIONS);

$folder = DOC_ROOT."/templates/profiles/default";
$dir = opendir($folder);
while($file = readdir($dir)){
if($file!="." && $file!=".." && is_file($folder."/".$file)){
copy($folder."/".$file,$profiles["path"]."/".$username."/".$file);
}//if
}//while
closedir($dir);[/code]

Now it inserts :username: into sql and updates that perfectly, BUT now i can't seem to get it to make the folders...any idea?
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/
Share on other sites

Usually if all your paths are correct it is a problem with permissions. If it is a Linux box make sure the profiles folder has at least 775 chmod. Some hosting companies, is it is a hosting company, do not allow 777 permissions and you will get an error. Also make sure you make the change to the folder recursive so everything under the folder gets chmod'ed also. Try echoing out your folder to make sure it is correct, and try to use document roots for folder creation and not reletive to the url. I think that is what you are doing but wanted to make sure :)

example
$doc_root = "/home/johnny/public_html/profiles/";

Ray
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117821
Share on other sites

Well in your function you are returning the mem_id. If you want the username then change what you are returning in your function if that is where you are getting your variable from.

Try adding this
[code]return $username;[/code]

then use $esurname for your folder

Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117829
Share on other sites

return $mem_id;  that is used for the SQL right? or is that wrong?

[code][code=php:0]
function create($md5=0){

if(!$md5)
$pline = "md5(':password:')";
else
$pline = "':password:'";

$sql_query="INSERT INTO members (email,username,password,fname,lname)
VALUES (':email:',':username:',".$pline.",':fname:',':lname:')";

$mem_id = $this->insert($sql_query);

$sql_query="INSERT INTO members_settings (mem_id) VALUES (".$mem_id.")";
$this->execute($sql_query);

$sql_query="INSERT INTO profile_access (mem_id) VALUES (".$mem_id.")";
$this->execute($sql_query);

if($GLOBALS["settings"]["track_profiles"])
$approved = 0;
else
$approved = 1;

        $sql_query = "INSERT INTO profiles(mem_id,joined,updated,last_visit,last_click,photo,photo_med,photo_small,approved,folder)
VALUES (".$mem_id.",".time().",".time().",".time().",".time().",'awaiting.gif','awaiting.gif','awaiting_small.gif ','".$approved."',':username:')";

        $username = ':username:';

        $this->execute($sql_query);

$sql_query="INSERT INTO network(mem_id,friends,friends_of_friends)
VALUES(".$mem_id.",',',',')";
$this->execute($sql_query);

$this->create_profile($username);

load_3rdparty("register",$this->values);

return $mem_id; [/code]
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117831
Share on other sites

did you put it in the function or just on the page. You have to put it in the functions because variables are not passed in and out of functions.

Try this to see what it returns
[code]<?php
function create_profile($username){
        $newfolder = $profiles["path"]."/".$username;
        echo $newfolder;
/*
include(DOC_ROOT."/themes/".$GLOBALS["THEME"]."/modules/profiles.inc.php");
if(!file_exists($profiles["path"]."/".$username))
mkdir($profiles["path"]."/".$username,PERMISSIONS);

copy($profiles["path"]."/default/index.php",$profiles["path"]."/".$username."/index.php");
chmod($profiles["path"]."/".$username."/index.php",PERMISSIONS);

$folder = DOC_ROOT."/templates/profiles/default";
$dir = opendir($folder);
while($file = readdir($dir)){
if($file!="." && $file!=".." && is_file($folder."/".$file)){
copy($folder."/".$file,$profiles["path"]."/".$username."/".$file);
}//if
}//while
closedir($dir); */
}[/code]

Ray
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117848
Share on other sites

/  <-- Echo Point?
Warning: Cannot modify header information - headers already sent by (output started at /home/ratemyfr/public_html/classes/Member.class.php:63) in /home/ratemyfr/public_html/functions/load_functions.php on line 75

Warning: Cannot modify header information - headers already sent by (output started at /home/ratemyfr/public_html/classes/Member.class.php:63) in /home/ratemyfr/public_html/functions/load_functions.php on line 75

Warning: Cannot modify header information - headers already sent by (output started at /home/ratemyfr/public_html/classes/Member.class.php:63) in /home/ratemyfr/public_html/functions/load_functions.php on line 14
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117852
Share on other sites

Well it seems that you have a problem with the variables. You said it is creating the directory ok but just with the wrong name. It is making the mem_id rather than the username. One other thing. Where is this function called on your regular page?? can you post that code.
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117855
Share on other sites

heh its all in smarty(the join page) but here it is
[code]<div class="padded">

<div class="columnWide">

{include file="boxes/simple.tpl" secheader=$language.sign_up_basic_info class="brown"}
{include file="forms/join.tpl" form="join"}
{include file="boxes/simple_close.tpl"}

</div>

{include file="divider.tpl" type="v"}

<div class="columnSmall">

{include file="boxes/tip.tpl" tip=$tip_message}

{if $banners.3}
<div class="banner-side">{banner area="3"}</div>
{/if}

</div>

</div>[/code]
Link to comment
https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117865
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.