Connecting Tech Pros Worldwide Help | Site Map

How to fix "undefined index: regexp code on line 1"

Newbie
 
Join Date: Mar 2008
Posts: 11
#1: Mar 17 '08
Hello, I am getting a Notice error on my website that says:
Notice: Undefined index: _created_formatted in C:\EasyPHP1-8\www\eP\components\com_jambook\jxtemplate.php(125 ) : regexp code on line 1

but I don't know what it means..I have no index _created_formatted on my php page and I can't find my mistake..Can someone help me with this?Which part of my code should I see for mistakes, and what kind of mistakes might these be?When I used to run my site on my local server, there was no problem, once I inserted it online, it created this Notice error. Thank you in advance for your time!
rpnew's Avatar
Familiar Sight
 
Join Date: Aug 2007
Posts: 180
#2: Mar 17 '08

re: How to fix "undefined index: regexp code on line 1"


Quote:

Originally Posted by mariaz

Hello, I am getting a Notice error on my website that says:
Notice: Undefined index: _created_formatted in C:\EasyPHP1-8\www\eP\components\com_jambook\jxtemplate.php(125 ) : regexp code on line 1

but I don't know what it means..I have no index _created_formatted on my php page and I can't find my mistake..Can someone help me with this?Which part of my code should I see for mistakes, and what kind of mistakes might these be?When I used to run my site on my local server, there was no problem, once I inserted it online, it created this Notice error. Thank you in advance for your time!

Hi,
Can you post your page code snap here..

Regards,
RP
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#3: Mar 17 '08

re: How to fix "undefined index: regexp code on line 1"


All it means is that the named index key does not exist. But note that is is just a notice, not an error! Your script will survive and won't crash. But is it, of course, a nuisance. Are you certain that you do not have or do not call or execute a script with that name defined?
If not, then the error is most likely in a script that you use from 3rd party software, like you have.

When not any of the above, show some code. And do it within the appropriate code tags according to the Posting Guidelines.

Ronald
Newbie
 
Join Date: Mar 2008
Posts: 11
#4: Mar 17 '08

re: How to fix "undefined index: regexp code on line 1"


I think the mistake must be in this function, it is the last function of the php file:

Expand|Select|Wrap|Line Numbers
  1. function parseTemplate( $variables="", $tmpl="" ) {
  2.         if ( $tmpl ) {
  3.             $this->setTemplate( $tmpl );
  4.         }
  5.         if ( $variables ) {
  6.             $this->setVars( $variables );
  7.         }
  8.         if ( isset( $this->content ) ) {
  9.             // Replace all variable values
  10.             $this->patterns['jxtvalue'] = "/{jxtvalue=([^}]*)}/ie";
  11.             $this->replacements['jxtvalue'] = "\$this->vars['\\1']";
  12.             // In addition to variables we will also replace any language strings found.
  13.             $this->patterns['jxtlang'] = "/{jxtlang=([^}]*)}/ie";
  14.             $this->replacements['jxtlang'] = "constant('\\1')";
  15.             // Show blocks only if a given variable has a value
  16.             $this->patterns['jxtshowif'] = "#{jxtshowif=([^}]*)}(.*){/jxtshowif}#Usie";
  17.             $this->replacements['jxtshowif'] = "(\$this->vars['\\1']) ? stripslashes('\\2') : ''";
  18.             // Show blocks if a given variable is empty
  19.             $this->patterns['jxtshowifnot'] = "#{jxtshowifnot=([^}]*)}(.*){/jxtshowifnot}#Usie";
  20.             $this->replacements['jxtshowifnot'] = "(\$this->vars['\\1']) ? '' : stripslashes('\\2')";
  21.             $this->output = preg_replace( $this->patterns, $this->replacements, $this->content );
  22.             return true;
  23.         } else {
  24.             return false;
  25.         }
  26.     }
  27.  
The notice error points to the line that begins with "$this->output=..." but I don't know what that error may be..
Member
 
Join Date: Nov 2007
Location: Russia, Saint-Petersburg
Posts: 82
#5: Mar 18 '08

re: How to fix "undefined index: regexp code on line 1"


Quote:

Originally Posted by mariaz

When I used to run my site on my local server, there was no problem, once I inserted it online, it created this Notice error. Thank you in advance for your time!

It means that error_reporting option in your local php.ini file does not allow to output notices.

Add this 2 lines in your script and you will see the same notice on localhost:
[PHP]ini_set('display_errors',1);
error_reporting(E_ALL);[/PHP]

The simpliest solution is to add @ operator in your script:
[PHP]@$this->output = preg_replace( $this->patterns, $this->replacements, $this->content );[/PHP]

But note - adding a lot of @ operators is not a good programming style.
Reply


Similar PHP bytes