SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fatal error: Cannot redeclare class??

    I am trying to generate an HTML based e-mail for a contact list and it does work correctly. The problem is as soon as I call the function more than once (because it is looping through a list) it attempts to redeclare the class (part of the HTML function). How can I "undeclare" the function or override this error?

    Here is some more info:

    in my function.php file I call this in my SendNEWPROJ function:

    include('class.html.mime.mail.inc');

    I get this error when the code runs through the loop of contacts as soon as it tries to load the second time:
    Fatal error: Cannot redeclare class html_mime_mail in...line 15

    This is the line that it has the problem with in that file:
    class html_mime_mail{

    Any ideas??

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could try using

    include_once('class.html.mime.mail.inc');

    But I wonder why you have that code inside a for loop at all? You might want to rethink the logic of your code. Generally, you would include a class definition at the begining of a script.

  3. #3
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the function for the HTML mail was built by someone else and they used the class. I am simply taking my data and passing it to the function over and over as many times as my list allows. The include_once did fix the problem, all seems to be okay now.

    Thanks Sid...

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Addtionally you could have moved the include() and the line that instantiates the class above the start of the loop, and that should fix it as well.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I am calling the function (which resides in a different file [functions.php]) each time I am needing to send a message. The function calls the include(class..), not my script with the loop. Kind of messy I know, but it is the only way I could get HTML encoded messages to work.

    Thanks for the feedback though, always appreciated.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •