the line $_SERVER['REQUEST_URI'] = MSU_REQUEST_URI;
Fills my errorslog with
Use of undefined constant MSU_PHPEX_PS - assumed 'MSU_PHPEX_PS' (this
will throw an Error in a future version of PHP)
So I was thinking to solved it with $_SERVER['REQUEST_URI'] = 'MSU_REQUEST_URI';
Than is the warning gone but the script isn't working any longer.
Any ideas?
The Problem you're having is that MSU_REQUEST_URI is undefined
This means whatever value you expected the constant MSU_REQUEST_URI to have, has not been set at the time of you executing $_SERVER['REQUEST_URI'] = MSU_REQUEST_URI;,
By surrounding MSU_REQUEST_URI with quotes like this 'MSU_REQUEST_URI' you are assigning the String Value (literally) "MSU_REQUEST_URI" to $_SERVER['REQUEST_URI'].
So as #alithedeveloper has asked in the comments:
What is MSU_REQUEST_URI supposed to be and how/where is it supposed to get it's value from?
You won't be able to solve your issue without figuring out why MSU_REQUEST_URI is not set.
Thanks for the response I found a other page with code about the MSU_REQUEST_URI
<?php
if(defined('MSU_REQUEST_URI')) {
return;
}
if(version_compare(PHPBB_VERSION, '3.1', '>=')) {
global $phpEx;
// Fixing Symphony rewrite compatibility
$_SERVER['PATH_INFO'] = '';
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
define('MSU_REQUEST_URI', $_SERVER['REQUEST_URI']);
if(
in_array(
basename($_SERVER['SCRIPT_NAME']),
array(
'viewtopic.'.$phpEx,
'viewforum.'.$phpEx,
'search.'.$phpEx,
'memberlist.'.$phpEx,
'faq.'.$phpEx,
'viewonline.'.$phpEx,
'ucp.'.$phpEx
)
)
) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].(!empty($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : '');
}
if(!defined('PHPBB_USE_BOARD_URL_PATH')) {
define('PHPBB_USE_BOARD_URL_PATH', true);
}
}
?>
Is that helping
Related
I am trying to perform an action when a specific user agent visits a link.
So i have my code like this:
//if browser is not Mozilla/4.2, then do something.
//but if its Mozilla/4.2, do another thing.
if(strlen(strstr($_SERVER['HTTP_USER_AGENT'],"Mozilla/4.2")) <= 0 ){
// Do something
} else {
//Else do another thing code follows.
}
The above code is working but it keeps giving this warning in the error log "Undefined index: HTTP_USER_AGENT"
The solution i saw used pregmatch, but am targeting only a single user agent.
Any help will be appreciated.
You simply need to check the existence of the index (HTTP_USER_AGENT) on $_SERVER and if it's not set then set it to empty string.
This can be achieved by doing;
$userAgent = ! empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if(strlen(strstr($userAgent,"Mozilla/4.2")) <= 0 ) {
// Do something
} else {
// Do something else.
}
Problem
I am getting a "Undefined index: node in include()" notice in Drupal for the below line of code. I've tried the below solution but I am still receiving the error. Any ideas?
Code
$url = drupal_lookup_path('alias', 'node/' . $related['node']->nid);
The solution I tried
isset($related['node']->nid) ? $related['node']->nid : "";
Question
Does anyone know why this error continues to occur?
The error suggests the $related array variable doesn't have a node index.
First, make sure you're retrieving the node object correctly.
Then, perhaps try it like this to avoid errors:
<?php
$url = '';
if (isset($related['node']) && is_object($related['node'])) {
$nid = $related['node']->nid;
$url = drupal_lookup_path('alias', "node/$nid");
}
This works on my test environment, but on my live server there is a later version of PHP which is throwing up an error and breaking my program
The code is
$oldFile = fopen("D:/ftpfolderreport/report/" . $last_file, "r");
while(!feof($oldFile))
{
$buffler = fgets($oldFile);
$bufflerArray = explode(",", $buffler);
$key = $bufflerArray[0];
$oldFileArray[$key] = $bufflerArray[1];
}
fclose($oldFile);
This line:
$oldFileArray[$key] = $bufflerArray[1];
Is throwing out this error
Notice: Undefined offset: 1 in D:\apps\wamp\www\Compliance2\compareFtpReports.php on line 57
I think this is to do with how I'm adding the $key variable inside the argument. I've tried it as ["$key"] and ['$key'] but it doesn't like it.
I have tried defining the key variable earlier in the program but still doesn't like it. I've been searching around online but can't find anything of help. Anyone any ideas?
Thanks,
Stephen.
add checks for empty
if (!empty($bufflerArray[1])) {
$key = $bufflerArray[0];
$oldFileArray[$key] = $bufflerArray[1];
}
Notice (8): Use of undefined constant inList - assumed 'inList' [CORE\Cake\Utility\ClassRegistry.php, line 168]
This notice has been bugging me for a while know, and I do not know how to fix it.. It was not really affecting my project earlier since its just a notice msg, but now, it is not letting me show an error message which I am trying to display to the user.
Iv got this function
public function validate_form(){
if($this->RequestHandler->isAjax()){
$this->request->data['Donor'][$this->params['form']['field']] = $this->params['form']['value'];
$this->Donor->set($this->data);
if($this->Donor->validates()){
$this->autoRender = FALSE;
}else{
$error = $this->Donor->validationErrors;
$this->set('error',$error[$this->params['form']['field']]);
}
}
}
The above is the action to which my post request submits to. Then it executes the following to display the error
if (error.length > 0) {
if ($('#name-notEmpty').length == 0) {
$('#DonorName').after('<div id="name-notEmpty" class="error-message">' + error + '</div>');
}
}else{
$('#name-notEmpty').remove();
}
The problem is that instead of the relevant error in my newly created div... I get that notice 8 from cake! Please if anyone knows why this is happening, I appreciate your aid on this one..
TLDR:
Do a project-wide find for 'inList' and find the spot where it either doesn't have quotes around it, or, if it's supposed to be a variable, is missing it's $.
Explanation:
You get that error when you try to use a PHP Constant that doesn't exist. Usually you're not actually TRYING to use a constant, but instead just forgot to wrap quotes around something or forgot to add the $ before a variable.
Examples:
$name = "Dave";
echo name; // <-- WOAH THERE, there is no Constant called name (missing $)
$people = array('Dave' => 'loves pizza');
echo $people[Dave]; // <-- WOAH THERE, no Constant called Dave (missing quotes)
Most likely somewhere else in your code you are using 'inList' as an array key but you don't have it quoted.
Example: $value = $myArray[inList];
It still works without quoting inList but it causes the notice message you're seeing.
I'm getting a series of:
"Undefined variable: loginError in /Library/WebServer/Documents/clients . . ."
entries in my Apache error_log which I would like to prevent. I have a simple login.php page which, if there's an error logging in sets the $loginError variable as such:
$loginError = '<p class="text-error">Login Error: '. $layouts->getMessage(). ' (' . $layouts->code . ')</p>';
If there's no error logging in it does this:
$loginError = '';
I then output any errors as such:
if ($loginError !== '') { //line 112
echo $loginError; /line 113
}
I'm getting the entries for the line 112 and 113 noted in my comments above. Anyone tell me how I can prevent the entries appearing? I'm using PHP Version 5.3.6.
thanks
Its saying you should check it is set before using:
One way is with isset()
if (isset($loginError) && $loginError !== '') {
echo $loginError;
}
But in your particular case you may as well use !empty()
if (!empty($loginError)) {
echo $loginError;
}
Hard to say without seeing the rest of your code. Trace through your logic to make sure that every possible branch initializes loginError at some point in its execution. Even better, set it to a default value before you go through the logic.