Jump to content

Error log : PHP Notice: Undefined offset


a1amattyj

Recommended Posts

Hello,

 

In my error log, its just plastered with:

 

[30-May-2008 06:14:25] PHP Notice:  Undefined offset:  2 in /home/smfnew/public_html/multi_operations/forum_functions.php on line 31

[30-May-2008 06:14:25] PHP Notice:  Undefined offset:  2 in /home/smfnew/public_html/multi_operations/forum_functions.php on line 31

[30-May-2008 06:14:25] PHP Notice:  Undefined offset:  2 in /home/smfnew/public_html/multi_operations/forum_functions.php on line 37

[30-May-2008 06:14:25] PHP Notice:  Undefined offset:  2 in /home/smfnew/public_html/multi_operations/forum_functions.php on line 37

 

Line 31:

if($serverhost[2] == 'smfnew' || $serverhost[2] == 'com'){
$forum_name = $forum_name1;
}else{
$forum_name = ''.$forum_name1.'_2';
}

Line 37:
if($serverhost[2] == 'smfnew' || $serverhost[2] == 'com'){
$domain1 = 'smfnew.com';
}else{
$domain1 = 'smffree.net';
}

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/107999-error-log-php-notice-undefined-offset/
Share on other sites

well it just means that the offset is not set

 

try using isset to avoid the error

 

if(isset($serverhost[2]) && ($serverhost[2] == 'smfnew' || $serverhost[2] == 'com')){
$domain1 = 'smfnew.com';
}else{
$domain1 = 'smffree.net';
}

 

Ok...well the offset is in reference to the "2" that you are using in your array ($serverhost[2]).

 

So this error is telling you that there is no element 2 in the serverhost array.

 

Try printing the array using print_r() to see what is in it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.