Languages :: PHP :: mkdir |
|||
| By: tacman7 |
Date: 12/09/2003 00:00:00 |
Points: 60 | Status: Answered Quality : Excellent |
|
In the page I wrote for another site I created directorys for each real estate listing using their mls number: mkdir($mls); worked fine. Now on this yahoo (geocities) site it doesn't work. I made a test file dir.php <?php echo"starting if"; if mkdir("test"){ echo" made directory"; }else{ echo"failed directory"; } ?> but it's just blank and does nothing. Any help appreciated, thanks phpinfo is at <A HREF="http://www.inlandvalley.net/info.php">http://www.inlandvalley.net/info.php</a> |
|||
| By: VGR | Date: 12/09/2003 16:28:00 | Type : Assist |
|
| 1) either you don't have the rights over the directory 2) or they deactivated the mkdir() function - it's rather standard to sort this out, execute php_info(); on the server and look for "mkdir" in the "--without" list ;-) |
|||
| By: tacman7 | Date: 13/09/2003 00:11:00 | Type : Comment |
|
| There are a lot of things they don't support: <A HREF="http://webhosting.yahoo.com/v/php/support.html">http://webhosting.yahoo.com/v/php/support.html</a> But mkdir seems to be something they do support. I can write to a file... from a script. I'll have to contact them. Thanks |
|||
| By: saknarak | Date: 13/09/2003 01:25:00 | Type : Assist |
|
| you may use full path to create file or directory. test.php ========================= <?php echo"starting if"; if (mkdir(dirname(__FILE__)."/test")){ echo" made directory"; }else{ echo"failed directory"; } ?> ======================== |
|||
| By: tacman7 | Date: 13/09/2003 02:11:00 | Type : Comment |
|
| I don't understand this line: mkdir(dirname(__FILE__)."/test") so, dirname is the directory I want to make the directory in? and what is (__FILE__). Sorry. Thanks |
|||
| By: tacman7 | Date: 13/09/2003 02:13:00 | Type : Comment |
|
| I am getting Failed directory echoed on my screen now that I put the quotes around the if clause. <?php if (mkdir("/test")){ echo" made directory"; }else{ echo"failed directory"; } ?> |
|||
| By: duniyadnd | Date: 13/09/2003 04:26:00 | Type : Comment |
|
| dirname(__FILE__) should be equivalent to $_SERVER['DOCUMENT_ROOT'] which basically points to your server directory. eg. /home/loginame/public_html so with $_SERVER['DOCUMENT_ROOT'].'/mynewdir'; is equivalent to: /home/loginname/public_html/mynewdir/ Make sure your root directory is chmod to 666 at least. It should be though if you keep updating your site. |
|||
| By: tacman7 | Date: 13/09/2003 11:23:00 | Type : Comment |
|
| This is what worked: <?php echo"starting if"; if (mkdir("test",0755)){ echo" made directory"; }else{ echo"failed directory"; } ?> Even though the second parameter is optional, on this server it's not. I finally read that you don't get errors till you create a logs directory then your errors will be in a scripts.log file in your logs directory. The error was: PHP Warning: Wrong parameter count for mkdir() in /root.php on line 3 |
|||
| By: duniyadnd | Date: 13/09/2003 11:28:00 | Type : Answer |
|
| eh.. that's weird that only with both parameter it works.. well.. whatever works.. :D |
|||
| By: tacman7 | Date: 13/09/2003 11:32:00 | Type : Comment |
|
| Well I answered the question myself but I appreciate the efforts, Thanks |
|||
| By: duniyadnd | Date: 13/09/2003 11:35:00 | Type : Comment |
|
| Heh.. if it was an option, should have given it to yourself. :D Thanks anyway |
|||
| By: saknarak | Date: 13/09/2003 16:05:00 | Type : Comment |
|
| __FILE__ is a specials variable referece to this file in test.php __FILE__ equal /path/to/test.php for example /path/to/a.php /path/to/somewhere/b.php a.php <? include("somewhere/b.php"); echo "a.php = ".__FILE__."\n"; ?> somewhere/b.php <? echo "b.php = ".__FILE__."\n"; ?> output b.php = /path/to/somewhere/b.php a.php = /path/to/a.php and function dirname(), it get dirname without tailing slash dirname("/path/to/a.php") == "/path/to"; so this function can reference path of current file you may use realpath(".") but result may difference depend on file that include other files Sak:) |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








