Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

mkdir in php

So I want to make a directory (I'm making a sort of blog type program) bsaed on the date, for instance, if a post is made, the data of that post is stored in a text file in the directory

day/month/year

(I don't want to use mysql.)

Anyways, I thought this would do it.

Code:
$date = date("d/m/y");

mkdir($date, 0700);

It returns

Code:
Warning: mkdir() [function.mkdir]: No such file or directory in C:\Program Files\EasyPHP 2.0b1\www\index.php on line 7
floppy jalopy

Any php experts around?
 

___

Sponsor

My first guess also would be the slashes.  You're asking it to make a directory "/08/" in "/02/25" which of course it can't find so it's spitting it out.  If you want a three level structure you need to make each directory individually; otherwise remove the slashes :)
 
this should be the solution to the OP problem,

I guess you might want to change your mkdir to use the recursive option...

http://php.net/mkdir
Code:
mkdir($date, 0700, TRUE);

secondly,you might want to change your date format to the ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601)
this'll make the enties easily sortable on date, because it'll put the year first, then the month (which is a part of a year), and then the day (which is part of a month)

examples:

2007-12-31
2008-06-14
2008-06-15
2008-07-03
2009-04-12

note that they're sorted on date ;)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top