lordphate Posted November 1, 2006 Share Posted November 1, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/ Share on other sites More sharing options...
craygo Posted November 1, 2006 Share Posted November 1, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117821 Share on other sites More sharing options...
lordphate Posted November 1, 2006 Author Share Posted November 1, 2006 Yeah i've checked it all..i'm thinking another file may be interrupting because it's making the folder as $mem_id instead of $username ... so i guss i have to find the other file eh? Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117823 Share on other sites More sharing options...
craygo Posted November 1, 2006 Share Posted November 1, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117829 Share on other sites More sharing options...
lordphate Posted November 1, 2006 Author Share Posted November 1, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117831 Share on other sites More sharing options...
craygo Posted November 1, 2006 Share Posted November 1, 2006 Try this to see what it is doing.$newfolder = $profiles["path"]."/".$username;echo $newfolder;Ray Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117835 Share on other sites More sharing options...
lordphate Posted November 1, 2006 Author Share Posted November 1, 2006 all its showing is "/" Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117842 Share on other sites More sharing options...
craygo Posted November 1, 2006 Share Posted November 1, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117848 Share on other sites More sharing options...
lordphate Posted November 1, 2006 Author Share Posted November 1, 2006 / <-- 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 75Warning: 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 75Warning: 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 Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117852 Share on other sites More sharing options...
craygo Posted November 1, 2006 Share Posted November 1, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117855 Share on other sites More sharing options...
lordphate Posted November 1, 2006 Author Share Posted November 1, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/25803-mkdir-errors/#findComment-117865 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.