File Handle Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zeroed
Forum Newbie
Posts: 1
Joined: Sun Jul 09, 2006 1:14 pm

File Handle Problem

Post by Zeroed »

Hi Folks,

I've been trying to Open a directory on my Hosted website (it's with GoDaddy - the account is enabled with PHP 4.3) and I'm having troubles obtaining a file handle. Here's the code:

Code: Select all

<?php

        $handle = opendir("d:\\hosted\\zeroed"); // $_SERVER['DOCUMENT_ROOT']
        $test = "This is a test.";
        if ($handle) echo "Handle";
        else echo "No handle.";

 ?>
It always outputs "No handle", no matter what directory I attempt to open. It could be DOCUMENT_ROOT, my home folder, or just ".". Can anyone tell me what I'm doing wrong? Am I testing $handle correctly? Do I not have permissions to open the folders? Any ideas?

-Zeroed
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

It may be the permissions issue. Try putting

Code: Select all

error_reporting(E_ALL);
before the code and see what it writes (as php manual says: "If path is not a valid directory or the directory can not be opened due to permission restrictions or filesystem errors, opendir() returns FALSE and generates a PHP error of level E_WARNING.").

PS: please use

Code: Select all

tags for php code.
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

You may want to read through godaddy's knowledge base. Last time I've had a client with godaddy's account it was a bitch to get anything done since they purposly disable bnch of PHP functions and most of them are related to file manipulation etc. Somewhere in the knowledge base you will find a list of functions that are disabeled. You can also run phpinfo() and look for the disable_functions to see what's not available to you.

Here's something from google

"Godaddy PHP Disabled Functions (Linux): All Posix functions disabled. Also, the following functions are disabled: fpassthru, file, mail, exec, system, passthru, popen, crack_check, crack_closedict, crack_getlastmessage, crack_opendict, fsockopen, psockopen, opendir, readdir, closedir, phpinfo"

http://www.imscart.com/blog/?postid=382

http://www.nutt.net/2006/07/06/godaddy- ... functions/

http://www.vbulletin.com/forum/archive/ ... 33216.html


Good luck!

~wtf
Post Reply