rgb192
asked on
PHP Notice: Undefined index: REQUEST_URI
$_SERVER['REQUEST_URI']
was working on another version of php that I had
but now I get notices and there is no way to eliminate these notices
error_reporting(0);
ini_set('display_errors', FALSE);
PHP Notice: Undefined index: REQUEST_URI
was working on another version of php that I had
but now I get notices and there is no way to eliminate these notices
error_reporting(0);
ini_set('display_errors', FALSE);
PHP Notice: Undefined index: REQUEST_URI
What server are you on? And what version of PHP?
$_SERVER['REQUEST_URI'] is available on Apache and IIS.
ASKER
using iis7 php 5.3.6 now
not sure of my old server
I think it was php 5.2 iis7
not sure of my old server
I think it was php 5.2 iis7
Here are two pages/programs that will display all of the SERVER variables available on your server. One is in Classic ASP and the other is in PHP. I added a third in a simple version of ASP.NET in case the Classic ASP doesn't run. The three programs will show slightly different results but they will show you what is available for those languages.
<%@ LANGUAGE = VBScript %>
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ASP Server Variables</title>
</head>
<body>
<h1>ASP Server Variables</h1>
<%
Dim item
For each item in Request.ServerVariables
Response.Write "<b>" & item & "</b>: " _
& Request.ServerVariables(item) _
& "<br>" & vbCrLf
Next
%>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PHP Server Variables</title>
</head>
<body>
<h1>PHP Server Variables</h1>
<?php
//reset($_SERVER);
foreach($_SERVER as $key => $value) {
echo "<b>$key :</b> $value<br />\n";
}
?>
</body>
</html>
<%@ Page Language = "VBScript" AspCompat="True" %>
<% Response.Buffer = true %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ASPX .NET Server Variables</title>
</head>
<body>
<h1 align="center">ASPX .NET Server Variables</h1>
<%
Dim loop1, loop2 As Integer
Dim arr1(), arr2() As String
Dim coll As NameValueCollection
' Load ServerVariable collection into NameValueCollection object.
coll=Request.ServerVariables
' Get names of all keys into a string array.
arr1 = coll.AllKeys
For loop1 = 0 To arr1.GetUpperBound(0)
Response.Write("Key: " & arr1(loop1) & "<br>")
arr2 = coll.GetValues(loop1) ' Get all values under this key.
For loop2 = 0 To arr2.GetUpperBound(0)
Response.Write("Value " & CStr(loop2) & ": " & Server.HtmlEncode(arr2(loop2)) & "<br>")
Next loop2
Next loop1
Response.Write ("<br>" & vbCrLf)
Response.Write ("HTTP_REFERER" & ": " _
& Request.ServerVariables("HTTP_REFERER") _
& "<br>" & vbCrLf)
%>
</body>
</html>
I see all the complaints in Google but I get $_SERVER['REQUEST_URI'] with PHP 5.2.17 on both IIS5.1 and IIS7.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please install this script on your server and post a link to it here so we can see how things are configured. This will be faster than guessing about your setup. You can take the script down later. Thanks, ~Ray
<?php phpinfo();
ASKER
suggestion works on both versions of php that I have used
now I can use $_SERVER['REQUEST_URI']
on php5.2.17
now I can use $_SERVER['REQUEST_URI']
on php5.2.17
Note that it isn't PHP but the server that reports that info to PHP. Different servers report different variables and some can be turned off by the people running the server. You can use the programs I posted above to see what your server reports.