$contentdirectory = '/dead-wave/dead-wave_content';
$contentlaunch = scandir($contentdirectory);
that's what I'm using to create an array from which I echo it's values using a for each statement. this works perfectly on my dedicated server, but once hosted on godaddy servers returns an error message 'failed to open dir: No such file or directory in...' now the directory path is certainly correct the actual problem is unknown to me. Any Thoughts?
Are you sure the path is correct? If the path is a subdirectory of your current directory, you should use 'dead-wave/dead-wave_content' instead of '/dead-wave/dead-wave_content'.
are you sure the path is correct? on a hosting you are usually rooted to a different directory (like /home/user1).
So the Path from above would be /home/user1/dead-wave/dead-wave_content/
you can do a
exec('pwd',$return);
print_r($return);
to find out where you actually are.
I'm not sure this is the same problem you're having but sometimes I can't use any file i/o functions when I'm running unit tests on top of Zend Server via Zend Studio even though they worked on Apache.
I think you need to rewrite you paths somehow making them relative to the server web directory constant. I'm not sure what that is but I'm sure there is one.
EDIT Oh! I don't think Apache recognizes '/toplevel/secondlevel' path writing style.
Related
This is structure I have. Page add-product.php is in folder public_html. Partial page ConnectQuery.php I need to access is in folder partial.
My project worked fine on localhost with wamp. Now I uploaded it to server and pathing got screwed.
Error I get:
Warning: include(/storage/ssd3/728/17657728/public_html/partial/ConnectQuery.php): failed to open stream: No such file or directory in /storage/ssd3/728/17657728/public_html/add-product.php on line 13
Line 13 in add-product.php is
include __DIR__ . "/partial/ConnectQuery.php";
EDIT: There is one more error
Warning: include(): Failed opening '/storage/ssd4/729/17661729/public_html/partial/ConnectQuery.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /storage/ssd4/729/17661729/public_html/add-product.php on line 13
usually paths never work the same way unless the development machine and server OS are same and they handle directories and files the same way -
Say if your development machine is Windows your Drive C:// will be there
its not the same in case of Linux and most of the servers are on linux and hence you're facing paths issue try using a path library in your case
in Node js there is path ;
which will point to current directory from you're running your project and from there on the paths will work with no issues .
Check the case in the spelling of the filename ConnectQuery.php.
Is it maybe connectQuery.php (like you wrote in another question)? Or connectquery.php?
Windows ignores differences in the case of file names, Linux doesn't.
If you are using PHP <= 5.2 than you have to try as below
$dir = dirname(FILE);
include($dir.'/partial/ConnectQuery.php');
Please try this and if you using some other php version than mention it here
I used to have problems with includes in my PHP projects between localhost and the actual server. I was able to get rid of this by using dirname(__FILE__). In your case you would use the following in your add-product.php
include dirname(__FILE__)."/partial/ConnectQuery.php";
This bypasses some weird standard include path errors by providing the full path of the current files directory.
I think this is all caused by directory separator issue.
Check the case of the ConnectQuery.php filename.
Windows is case-insensitive which means that WAMP will find a file named connectquery.php even if you requested CONNECTQUERY.php
Linux won't. If you request a file named CONNECTQUERY.php, it will search for this exact filename.
I advise you to adopt a convention : only lower-case letters for filenames. This will save you a lot of headaches.
I get the following error message when i try to run some php code on a site I have built in XAMPP
Error 0: Cache directory 'C:\xampp\htdocs\eve-charinfo/.pheal-cache/722091/n3Yeskd6U90NyJXG5m5O6p5Rid9NVKKfJBaSVx3j9S3xApfAiYhBBSabzZas7VCr/account/APIKeyInfo/' isn't writeable
"Pheal is a PHP library for accessing the EVE API, its basically a PHP port of EAAL it uses some metaprogramming foo to ensure it does not need changes when the EVE API is changed. it also contains a simple file cache that can respects the EVE APIs cache timers."
Somewhere in your PHP code will be a line that looks like this ....
PhealConfig::getInstance()->cache = new PhealFileCache('/your/path/to/the/cache/');
Make sure this is a valid windows directory.
Check you have write access to the directory. If its in a webroot
directory you probably dont.
Make sure the full path starts and ends with a '/' character Use a *NIX like file
path, not a DOS type i.e. use '/' as a directory separator
Do not include the C: drive directive
Probably best not to use a '.' in a windows file path but will likely
still work
And of course, your best source of answers about pheal is the EvE online Technology forum.
While cleaning up some old php scripts I've noticed some weird behavior with require/include statements when I try to use variables.
On the live server, the following code works fine..
<?php
$test = "http://localhost/elearning/trunk/mypage.php";
require "$test";
?>
..but on my XAMPP installation ((basic package) version 1.6.7) I receive the following error:
Warning: require() [function.require]: URL file-access is disabled in the server configuration in C:\Documents and Settings\username\Desktop\xampp-win32-1.6.7\xampp\htdocs\elearning\trunk\test.php on line 22
Warning: require(http://localhost/elearning/trunk/mypage.php) [function.require]: failed to open stream: no suitable wrapper could be found in C:\Documents and Settings\username\Desktop\xampp-win32-1.6.7\xampp\htdocs\elearning\trunk\test.php on line 22
Fatal error: require() [function.require]: Failed opening required 'http://localhost/elearning/trunk/mypage.php' (include_path='.;C:\Documents and Settings\username\Desktop\xampp-win32-1.6.7\xampp\php\pear\') in C:\Documents and Settings\username\Desktop\xampp-win32-1.6.7\xampp\htdocs\elearning\trunk\test.php on line 22
If I copy+paste http://localhost/elearning/trunk/mypage.php (directly from the error) into my browser, mypage.php loads. Is this an error in my configuration, or my approach?
You can't use paths that start with http:// on some servers because of security. What you want to use instead is a directory path.
You can get your current directory path by doing something like
echo $_SERVER['DOCUMENT_ROOT'];
that will give you your directory path from the root folder of the server. That is the path you want to use to include/require stuff.
If you didn't quite understand that, try this.
There are two types of paths:
World Wide Web Paths:
http://example.com/directory/file.php
Server Directory Paths:
/home/usr/www/site/html/
The Server directory path is where your files are located on the server's hard drive. Much like your computer's hard drive, it is never changes unless you move the files. On the other hand, The World Wide Web Path (the one everyone uses to access your website) can change based on what domain you are using, where your Document Root is pointing, Mod Rewrites, and more.
Note: The Document Root is the top most directory that your server serves files from. So, if you had index.php in your document root, it would show up like this on the web:
http://example.com/index.php.
When PHP looks for a file, it uses the Server Directory Path, because it is running on the server. When Javascript, which runs from the user computer, wants to look for a file, it uses the World Wide Web path to access it, because it isn't accessing it from the server.
I really hope that somewhere in there, something made sense.
try require "./mypage.php"
not the whole exact directory
PHP isn't smart enough to know that you're including from the same server when you use URL notation like that, so it thinks you're grabbing files from a seperate server (which can be dangerous).
Your server configuration is set to disallow loading these external files (evident by the error message "URL file-access is disabled in the server configuration"), so it's failing.
Since you're on the same server, you can simply use relative paths, like:
require_once 'mypage.php'
Don't use a path like that ... use a relative path or absolute path.
Example
require 'mypage.php'
i'm using Xampp. When I tried to do this earlier, it worked, but now it is not working.
I'm trying to make a directory in my www folder to hide it from baddies who steal files.
Each user gets their own folder in uploads to put their files on.
Xampp uses apache, and Xampp is a local web server. It allows me to design websites without the need of an online host. The www folder is in my C:\program files\xampp\php\www\ and I need to make a directory there. I know it's possible because i've done this before, I have just forgotten how to make it happen.
When I make a directory I use:
$uploaddir1 = "xampp/php/www/uploads/".$esclcusername."/";
mkdir($uploaddir1,0777);
Do I need to include C:\program files\ before xampp?
And finally, how would this be possible on a real online web host?
I saw your question here and searched some on google. This is what i found:
mkdir("D:/hshome/rubygirl58/gameparody.com/clansites/".$sitename."/lib", 0777)
So yes, I think you have to include the complete path.
Greetings,
Younes
you need to make sure that you give permisions to the parent folder to create dirs in it (0777)
to get the full path you can use dirname(FILE) wich will return the path for the directory of the file in wich it is runned
I'm on a Windows machine. This seems like it should be unnecessary, but when I do it, everything suddenly works. Is there something wrong with my path? Do I need to add something to it to avoid having to copy DLLs?
Apache like any application will assume that the file is located in the same directory as the Current Directory path (check out http://en.wikipedia.org/wiki/Working_directory). If it's not there. The current working directory is USUALLY the same directory that httpd.exe (main executable) is in but it can actually be different if you do something like
C:\Apache2>bin\httpd.exe
In this case the Current Working directory is C:\Apache2 rather than C:\Apache2\bin.
If if the file isn't found there the application will naturally traverse the PATH environment variable. The PATH environment variable is a semi-colon or comma separate list of paths) to find the file.
Start -> Run -> Type "cmd.exe" and then in the Command Prompt type "echo %PATH%" to see the current path you have.
Finally, if the file wasn't found it will just error out.
As a tip you can actually track what files an application is trying to load and where they load them from by using Process Monitor. http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
I've used this tool to solve load DLL problems in Apache before and other applications as well. Just simply add a filter for the app you are running and have it only sniff out file reads.
I donot know the internals of MySQL and apache.
My thought is this. Internal of your application is using libmysql.dll. And it seems that path is not proper so it searches in PATH environmental variable. apache/bin will be there in PATH directory. So it is taking the dll from this path. If the dll is not present in that path I think it fails to load and hence fails.
EDIT: Added the solutions which were added in comments
Try rebooting your machine. I had the same issue with mysqlpp library. Path was pointing to mysql bin dir but it still couldnt find libmysql.dll – Daniel (Jan 26 at 6:55)
Apache might be running with credentials different from your own (almost certainly so if you're running it as a service.) Try placing the dirs in the SYSTEM path, not the USER path. – moocha (18 hours ago)