0

Anyone got an idea why this code is not working? I just get a blank page. This code is not from me. It is tutorial code and worked in the video I have watched.

<!DOCTYPE HTML PUBLIC "-/W3C//DTD HTML 4.01 Transitional//EN" http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Example</title>
    </head>
    <body style="width: 960px; margin: 25px auto 0;">
        <?php
            $cur = getcwd();

            if (mkdir($cur . '/uploads', 0777)) {
                echo 'Directory created';
            } else {
                echo 'Directory not created';
            }
        ?>
    </body>
</html>
Dario B
  • 1
  • 1
  • 5
    It's most likely a permission error. Check your error log. A good idea would also be to turn `display_errors` on while you develop. Read how here: [How do I get PHP errors to display?](http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – Magnus Eriksson Jan 08 '17 at 11:56
  • @MagnusEriksson Where do I find the error log? – Dario B Jan 08 '17 at 12:21
  • check what you have got from this $cur = getcwd(); as output – mizan3008 Jan 08 '17 at 12:22
  • It depends on what your system is. Apache? Niginx? Windows? Linux? Mac? Mamp? Wamp? Xampp? Try google "php error log for xxx on yyy" (replacing xxx and yyy with the correct environment) – Magnus Eriksson Jan 08 '17 at 12:23
  • 1
    Show apache error log – A K Jan 08 '17 at 12:48
  • A really dumb question but if I open a .php with an internet browser and it contains some sample text like 'echo "test";' the word test should show up ,right? – Dario B Jan 08 '17 at 12:51
  • @DarioBCrazyBadger yes. You should read Magnus' link which will help you enormously as to finding out why things fail (or work) as they do. You can [read here about how to ***store*** PHP errors in log files](http://stackoverflow.com/questions/3531703/how-to-log-errors-and-warnings-into-a-file) and how to access them. – Martin Jan 08 '17 at 13:29
  • (actually I have just seen @MagnusEriksson has posted the same link. Read it, apply it, and then read your error log.... the answer will appear!) – Martin Jan 08 '17 at 13:30

0 Answers0