php ereg function help?

  • mikewooten
  • Novice
  • Novice
  • mikewooten
  • Posts: 24

Post 3+ Months Ago

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");    
  2. function datecheck($intext) {  
  4.    $result = ereg("([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})", $intext, $trashed);  
  6.    if ($result) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }  
  10.  echo("\"$intext\" $isamatch<br>\n");    
  14. }

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?

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4579
  • Loc: Maryland

Post 3+ Months Ago

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

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 28 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

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.