PHP code fatal error.... somebody help

Discussion in 'PHP' started by valandil, May 9, 2008.

  1. #1
    Hey guys, I'm using dlguard to protect my download page. I copied and pasted the code it generated and I received this error:

    Fatal error: Cannot redeclare cbvalid() (previously declared in /home/valandil/public_html/cbthankyou.php:13) in /home/valandil/public_html/dlguard/cbcode.php on line 135
    Code (markup):
    Line 128 - 135 of cbcode.php is

    $q[8] = "\0";
       $finalstring = "";
       for($i=0;$i < 8;$i++)
         $finalstring .= $q[$i];
       if (!strcmp($cbpop, $finalstring)) return 1;
       else return 0;
     }
    Code (markup):
    Anyone help? Thanks.
     
    valandil, May 9, 2008 IP
  2. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    It looks like the function is being declared twice on one of the files used. Check your file cbthankyou.php for where the function cbvalid() is being declared.

    Removing one of them should fix your problem.
     
    chopsticks, May 9, 2008 IP
  3. valandil

    valandil Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What if both scripts I'm using needed that function. I checked that, yes, cbthankyou.php do have a cbvalid() function but it's part of the script. The new script I want to use also has that...
     
    valandil, May 9, 2008 IP
  4. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Well thats your error.

    You are going to have to find some way to remove one of them otherwise it won't work.
     
    chopsticks, May 9, 2008 IP
  5. Sabbir

    Sabbir Banned

    Messages:
    210
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #5
    as you decalred it , then do not declare it again , just use the previously declared varibale.
     
    Sabbir, May 9, 2008 IP
  6. kreoton

    kreoton Peon

    Messages:
    229
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    surround you function in if sentence :

    
    if (!function_exists('cbvalid'))
    {
        function cbvalid ()
        {
            /* function code */
        }
    }
    
    PHP:
     
    kreoton, May 10, 2008 IP
  7. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Or rename one of the functions.
    Or even better, use classes
     
    matthewrobertbell, May 10, 2008 IP
  8. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #8
    Chances are the function is redeclared in a loop, so renaming would stop the function being called altogether. Can't see how a class would solve the problem.

    Do as kreoton suggested and use function_exists.

    Jay
     
    jayshah, May 10, 2008 IP