php ereg function help?

  • mikewooten
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 21, 2004
  • Posts: 24
  • Status: Offline

Post April 21st, 2004, 4:40 pm

i'm using the datecheck () ereg function inside of a while loop and its giving me this error.
here's the function:




PHP Code: [ Select ]
 
function datecheck($intext) {  
 
   $result = ereg("([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})", $intext, $trashed);  
 
   if ($result) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }  
 
   
 
 echo("\"$intext\" $isamatch<br>\n");    
 
   
 
}
 
 
  1.  
  2. function datecheck($intext) {  
  3.  
  4.    $result = ereg("([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})", $intext, $trashed);  
  5.  
  6.    if ($result) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }  
  7.  
  8.    
  9.  
  10.  echo("\"$intext\" $isamatch<br>\n");    
  11.  
  12.    
  13.  
  14. }
  15.  
  16.  



here' s the error:

Fatal error: Cannot redeclare datecheck() (previously declared in /home/username/public_html/folder/thanks2.php:332) in /home/username/public_html/folder/thanks2.php on line 332


when i take the function outside of the loop, the form on the page just keeps copying itself all the way down the page, i'm guessing it has something to do with the loop, but i'm not sure whats going on with it, and why its giving me this error if
i don't have 2 functions with the same name? also i don't have an include file with the same function in that file.
can anyone tell me how i could fix this so that i don't get this error?

thanks
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 21st, 2004, 4:40 pm

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post April 22nd, 2004, 5:12 pm

What is happening is each time you run the loop you are redeclaring datacheck(); you'll need to move that function to right before your loop, or at the top of the page, or better yet a separate functions.php. Sorry I just like beeing uber-organized with my scripting :-P
Pixel Acres V2

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 99 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.