Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP4 ISAPI to PHP5 FastCGI Issues

Status
Not open for further replies.

menkes

Programmer
Nov 18, 2002
47
US
As the subject says, I am converting an existing site. Specifically from 4.3.9 to 5.2.8 on Windows 2003 server using IIS6.

I seem to have two problems that, although I have read the manual and many sites, I just cannot get my brain around.

1. Scope: Something has changed here, but I do not know what. I did a full compare of the php.ini files and the only differences relate to cgi and some directory changes.

An example:
Each page has the line require("fileA.php"). In fileA.php are several more requires (database, globals, session management). One of those is require("fileB.php"). In fileB.php is the user-defined function sendtoX().

So index.php requires fileA.php, which requires fileB.php. Then index.php calls the function sendtoX.

On the PHP5 FastCGI server I get "PHP Fatal Error: Call to undefined function sendtoX in index.php at line 123".


Problem 2 (More a question): The existing code that has run fine in PHP4 references associative arrays in any of three ways (both PHP and user arrays).

Example1: $_SESSION[user] or $_SESSION['user'] or $_SESSION["user"]

Example2: $my_array[id] or $myarray['id'] or $myarray["id"]

PHP5 does not like this. Is there any way to keep the code as-is (for now at least), or must I standardize?

Thanks for reading.

- Scott
 
Feherke, excellent! Thanks for the reference. That clears up #2 for me quite nicely
 
require(<just a file name or relative path>) is almost always wrong, but it takes some time to blow up in your face.

PHP's ways to resolve a path are not entirely straightforward. Read about it in the manual. To cut the story short, give the full path when including other files. So if it is in the same directory:
Code:
require_once(dirname(__FILE__) . '/FileA.php');
__FILE__ is always correct to be the current script, while the includes work to the originally called file, which your script cannot know beforehand. Also, you can set search paths and restrictions in php.ini, so differences may come from the config.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Thanks for the response.

I updated my requires to be explicit in path. Unfortunately, same result.
 
is the include path different between the two server instances? cf php.ini to determine the answer. or call phpinfo().
 
The include is not the problem, but I believe you sent me on the right track.

I expected that the script would throw an error if it could not load the required file. But, then I noticed images were not loading. If I spell out the path to the image it works though.

works

./imgdir/img.png does not work

So I rechecked phpinfo() and found on the old server Virtual Directory Support = enabled, where it is disabled on the new.

Following this I searched...amazing how unhelpful my search was. I am thinking it is an IIS issue (?), but still looking.

Note: I installed PHP4 (old sever) using the .msi package. I did the PHP5 install manually in order to set up FastCGI correctly (was highly recommended).

Did I miss something?
 
I expected that the script would throw an error if it could not load the required file.

It should. However, if all errors and warnings are off, you won't see that error message. If this is your development server, it is best to switch all errors and warnings on. On a production server, best keep them off. But temporarily switching them on to see what the problem is probably won't hurt.

I assume the above relative and absolute paths point to the same thing? That would be really odd. Does the web server user have enough rights to see the files? The web server runs as a user, usually with fairly low permissions to be safe. But if it isn't even entitled to read the pages that it serves, it cannot server them.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Well, definitely a path issue. The function call failing was a false lead. I now get the correct error about the required file missing. I do have Errors on. Not sure why it was misleading me....

So the path points to c:\ which is not where i put files. I seem to recall there is an issue with FastCGI and how you set up paths. Will have to research that more.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top