Results 1 to 1 of 1
Jan 19, 2005, 07:27 #1
- Join Date
- Mar 2001
- Northwest Florida
- 0 Post(s)
- 0 Thread(s)
PHP No input file specified. - TIP
A long while back I wrote a product catalog system that relies on the passing of values via index.php/121/1/ where 121 is the catalog id and 1 represents the page number. When I recently installed the catalog (for my client) on their hosting companies server I get the "No input file specified" error.
There have been countless people stuck on this problem and none of the resources I found provided a clear cause of the problem and a work around. So, I would like to share my findings, hopefully, someone may find this usefull.
Most of you know about search engine friendly urls such as :
Most web severs can handle this without a problem. However, some web hosting companies have PHP installed as a CGI-MODULE and FORCE-REDIRECT turned on. In this case you will get the "No input file specified" message. It simply means that it is treating index.php/121/1/ literally all together as a single file name. If you where to call index.php?catalogid=121&page=1 instead, your script would work perfect.
Being on the cautious side, I don't like passing variable names and values from page to page in public view. Call me paranoid, but, there is always someone out there that is going to fiddle with the values being passed just to see if they can screw up your server.
My solution is simply to create an array, convert it to a string that can be passed to another page, and finally the receiving page convert the string back into the array.
// example to convert array into a string :
$myvars = ('Catalogid'=>121,'Page'=>2);
$params = base64encode(serialize($myvars));
echo "<a href=\"index.php?params=$params\">My Link</a>";
// example to convert string back into array :
$myvars = base64decode(unserialize($params));
echo $myvars['Catalogid'] . "  " . $myvars['Page'];
The story continues...
After several hours of recoding my product catalog (and shopping cart system) I realized the advantage of the methods explained above.
1) you can pass values via index.php/828729jJVIAKJSKALJSLA/ on servers which support it. The 828... represents the encoded string.
2) you can pass values via index.php?params=82872... on servers that generate the "No input file specified" message.
In short, by placing a variable at the top of your script you could do something such as this to switch between paramater passing methods :
$USEFRIENDLY = "?params=";
$USEFRIENDLY = "/";
echo "<a href=\"index.php" . $USEFRIENDLY . "$params\">My Link</a>";
I surely hope this helps someone out.