server configuration Help

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
rcity
Forum Newbie
Posts: 3
Joined: Tue Jan 06, 2004 2:21 pm

server configuration Help

Post by rcity »

Server: W2K3
IIS: 6
PHP: 4.3.4

Does anyone know what I need to change on the server to make this script work?

I have a script that works fine under PHP 4.3.2, but not PHP 4.3.4. The script creates a search engine friendly URL, but with PHP 4.3.4 it displays a not found error. It appears that the server is expecting the random number created by the script to be a file, not a parameter for the php file. I used the php.ini file from the working PHP version, same problem. I upgraded myW2K test server to PHP 4.3.4 and it had the same problem. I downgraded it to 4.3.2 and it's working again. The original URL is:

http://www.yellowpagecity.com/27-9.php

This file creates a link that contains the variable "message" followed by a random number for it's value.

The URL it creates is:

http://www.yellowpagecity.com/27-9.php/message/899

The error messages are:

Warning: Unknown(C:\Websites\ypcity\27-9.php\message\899): failed to open stream: No such file or directory in Unknown on line 0

Warning: (null)(): Failed opening 'C:\Websites\ypcity\27-9.php\message\899' for inclusion (include_path='.;c:\php4\pear') in Unknown on line 0



Thanks to the person that left the sample script a couple of months ago finally got time to get back to this problem. Sorry, I lost your name.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Hard to help you without seeing the code. . .
rcity
Forum Newbie
Posts: 3
Joined: Tue Jan 06, 2004 2:21 pm

The Code

Post by rcity »

<?php
$test = $_SERVER['PHP_SELF'];
echo 'script_filename is: '.$test.'<br>';

function fetch_path() {
$_PATH = array();
if( isset($_SERVER['PATH_INFO']) ) {
$getdata = explode('/', $_SERVER['PATH_INFO']);
$getcount = count($getdata);
if( $getcount % 2 == 0 ) {
$getdata[] = '';
$getcount++;
}
for( $i = 1; $i < $getcount; $i += 2) {
$_PATH[$getdata[$i]] = $getdata[$i+1];
}
}
return $_PATH;
}

if( isset($_SERVER['PATH_INFO']) ) {
$pathsample = fetch_path();
echo"<br> pathsample is: ".$pathsample['message']."<br>";
}
else{
echo'<br> No Path Info<br>';
}
/* $path82 = $_SERVER['PATH_INFO'];
echo $path82.'is<br>'; */

if(isset($_SERVER['PATH_INFO']))
{
//remove .html from the end
$path = str_replace(".html", "", $_SERVER['PATH_INFO']);

//remove leading slash
$path = substr($path, 1);

//iterate over parts
$pathVar = array();
$v = explode("/", $path);
$c = count($v);
for($i=0; $i<$c; $i += 2)
{
$pathVar[($v[$i])] = $v[$i+1];
}
print("You are viewing message " .
"{$pathVar['message']}<br>\n");
}

//pick a random ID
$nextID = rand(1, 1000);

print("<a href=\"{$_SERVER['PHP_SELF']}/message/$nextID\">" .
"View Message $nextID</a><br>\n");
?>
Post Reply