loong
asked on
PHP getting - PHP Notice: Use of undefined constant
Hello,
I am getting this error in our windows server 2008 environment.
PHP Notice: Use of undefined constant act - assumed 'act' in C:\mydomain.com\admin\acti on.php on line 4
PHP Notice: Undefined index: act in C:\mydomain.com\admin\acti on.php on line 4
The script is as per attached. Anyone can help?
action.txt
I am getting this error in our windows server 2008 environment.
PHP Notice: Use of undefined constant act - assumed 'act' in C:\mydomain.com\admin\acti
PHP Notice: Undefined index: act in C:\mydomain.com\admin\acti
The script is as per attached. Anyone can help?
action.txt
ASKER
Well I am uncertain as this files have been move over from one site to another. Before it was move, the site is running. After moving to our new environment, that's what we get. The only difference we could see is that the previous PHP version was 5.25. and now it is 5.2.17.
The problem with code snippets is that they don't allow you to see the whole picture. Do you know whether $r is defined in the inc/inc.php file? Is there any code above the snippet you showed me? It is kind of strange because two lines below the problem you redefine $r.
Try placing this code on line 3 and tell me if you see anything:
foreach($r as $key => $value) {
echo "<script language='javascript'>alert('key = " . $key . ", value = " . $value . "');</script>";
}
ASKER
Under inc/inc.php
<?
session_start();
require_once("inc/connect. php");
require_once("inc/function .php");
$r=$_REQUEST;
?>
<?
session_start();
require_once("inc/connect.
require_once("inc/function
$r=$_REQUEST;
?>
ASKER
The code I had attach as action.txt on my first mail
ASKER
Putting the code still the same error
PHP Notice: Use of undefined constant act - assumed 'act' in C:\mydomain.com\admin\acti on.php on line 7
PHP Notice: Undefined index: act in C:\mydomain.com\admin\acti on.php on line 7
only changes are the line since I had place the line.
The file that browsing and giving error is action.php which it should as per my previous attach action.txt. Something like that:-
<?php
require_once("inc/inc.php" );
foreach($r as $key => $value) {
echo "<script language='javascript'>aler t('key = " . $key . ", value = " . $value . "');</script>";
}
$act = $r[act];
$time = time();
$r=$_REQUEST;
switch ($act)
{
PHP Notice: Use of undefined constant act - assumed 'act' in C:\mydomain.com\admin\acti
PHP Notice: Undefined index: act in C:\mydomain.com\admin\acti
only changes are the line since I had place the line.
The file that browsing and giving error is action.php which it should as per my previous attach action.txt. Something like that:-
<?php
require_once("inc/inc.php"
foreach($r as $key => $value) {
echo "<script language='javascript'>aler
}
$act = $r[act];
$time = time();
$r=$_REQUEST;
switch ($act)
{
Sheesh, you have a bunch of nested files above that code. $r could be anywhere.
I see you placed my code, but did the alerts pop up when you ran it? If so, what were the values of $r?
I see you placed my code, but did the alerts pop up when you ran it? If so, what were the values of $r?
ASKER
no pops out. exactly similar error with out without your codes. :(
Actually still weird as why previously it was working on another server but not this time...hmm
Actually still weird as why previously it was working on another server but not this time...hmm
I looked at the code that was posted and the first part is simply out of order. This part:
$act = $r[act];
$time = time();
$r=$_REQUEST;
should be:
$time = time();
$r=$_REQUEST;
$act = $r['act'];
And there isn't a PHP function called 'redirect'. It should be:
header("Location: pgh.php") ;
http://us.php.net/manual/en/function.header.php
$act = $r[act];
$time = time();
$r=$_REQUEST;
should be:
$time = time();
$r=$_REQUEST;
$act = $r['act'];
And there isn't a PHP function called 'redirect'. It should be:
header("Location: pgh.php") ;
http://us.php.net/manual/en/function.header.php
No popups means that $r is not an array. Are you sure you guys made no changes to the code?
ASKER
Still getting this error this time at line 6 which is $act = $r['act'];
PHP Notice: Undefined index: act in C:\mydomain.com\admin\acti on.php on line 6
PHP Notice: Undefined index: act in C:\mydomain.com\admin\acti
ASKER
Yeah no changes as we just pulled the code and place it in the new server
Wait, $_REQUEST comes as a result of a form submission. Where is your form?
ASKER
Its actually a login page
Maybe u try this -
http://124.150.143.162/admin/loginnew.php
putting in dummy login id and password and u will see the error
Maybe u try this -
http://124.150.143.162/admin/loginnew.php
putting in dummy login id and password and u will see the error
OK, I see that in your form there is no way to post an act index. That could be your first problem.
Did you change the input form at all in your move?
Did you change the input form at all in your move?
ASKER
I had just bring over the latest file again to the new server. Still the same. Actual domain which yet to point is http://www.palaceofthegoldenhorses.com.my/admin/loginnew.php
We set that ip is to test the whole application before pointing.
We set that ip is to test the whole application before pointing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Its ok we found the problem was due to reporting error is not off..
I'm sorry, but turning error reporting off will not solve your problem, simply get rid of the annoyance of the warning message, but not resolve the error you have in your coding.
If you are saying that error reporting was off on your original site it may be that this code never worked.
If you are saying that error reporting was off on your original site it may be that this code never worked.
ASKER
Yeah could be actually...Hmmmm
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
customer ok to turn off notice
To anyone reading this thread... Do not do what loong is doing here -- it is technically incompetent and potentially dangerous.
You don't want to be that guy!
You don't want to be that guy!
Open in new window