canimbenim
canimbenim

Reputation: 649

include() it does not work

I have problem that on server include() function does not want to work and I have no idea why?

I have:

 if (file_exists('/home/p002/htdocs/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php')) {
    echo "1 works";
} else {
    echo "The file 1 does not exist";
}

if(include "$_SERVER[DOCUMENT_ROOT]/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php" == 'OK')
{
    echo 'INCLUDE 1 works';
}
else
{
    echo 'Step 1 fail';
}
if(include '/home/p002/htdocs/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php' == 'OK')
{
    echo 'INCLUDE 2 works';
}
else
{
    echo 'Step 2 fail';
}

It returns: 1 works Step 1 fail Step 2 fail I have no idea how to force it to work. HELP I use zend framework and this file is in the library (parallel to zend -libraries - directory but it does not want to work too without the include directory :/


It is really strange for me as when I add:

include ("/home/p002/htdocs/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php");

And it is correct path I have only blank page! But when I add:

include ("/homedddd/p002/htdocs/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php");

And it is wrong path the page is not blank, it looks like working OK. It mean something is wrong with this IntelliSMS library it does not work with my server but I do not know why? Probably server blocking sending sms or something? Do you have any idea? This library is from http://intellisms.co.uk/sms-gateway/php-sdk/ Maybe there is problem that it needs the OpenSSL extension module? What should I do it to start works?

Upvotes: 2

Views: 1461

Answers (4)

Demento
Demento

Reputation: 4307

In the first block of code you found out, that /home/p002/htdocs/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php exists. When you try to include this file, you never use the exact same string. If you do, it should work.

Edit: You tried that and it failed. In that case it looks like a permission issue. If you do not have read permissions on that file, the first test will work, but including the file will fail.

Upvotes: 1

Gussi
Gussi

Reputation: 553

Here's what you're doing wrong, you were actually trying to include FALSE in every single attempt. Doing something like this

include '/path/to/file.php' == "OK";

equals that

include FALSE;

This is probably what you wanted to do

if((include '/path/to/file.php') == "OK") { echo("works"); }

Other SO users overlooked this fact because your path is so long, the comparison gets hidden in your code block.

Upvotes: 0

mario
mario

Reputation: 145512

You should never use the \ backslash in path names. Use the forward slash / which works on both Windows and Un*x servers.

Also the base directory name is unlikely to be identical on both servers. Make it relocatable and replace /home/p003/htdocs with DOCUMENT_ROOT like so:

include "$_SERVER[DOCUMENT_ROOT]/Project2/library/IntelliSMS/SendScripts/IntelliSMS.php";

Notice the double quotes.

I would further recommend to avoid mixed-case filenames if possible.

Upvotes: 0

Joshwaa
Joshwaa

Reputation: 840

You've changed your slashes around. This may be a problem.

Upvotes: 0

Related Questions