Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    75
    Thanks
    9
    Thanked 2 Times in 2 Posts

    Arrow Cannot redeclare hex2str

    hello first let me say thank you for any replys

    Fatal error: Cannot redeclare hex2str() (previously declared in /home/whathere/public_html/includes/session.php:663) in /home/whathere/public_html/includes/session.php on line 670

    how do I fix this please?

    Code:
    function hex2str($hex)
    {
      for($i=0;$i<strlen($hex);$i+=2)
      {
        $str.=chr(hexdec(substr($hex,$i,2)));
      }
      return $str;
    }
    
    ?>
    This is the from session.php line 663 to 672

    Thank you

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    Have you attempted to include this file twice?

  3. #3
    New Coder
    Join Date
    Feb 2011
    Posts
    75
    Thanks
    9
    Thanked 2 Times in 2 Posts
    no I checked that and as far as I can see there is not

    I will post the code from the profile too

    Code:
    <? require('includes/pages/header.php');
     ?>
    
    
    <? 
    $mode = $_GET['mode']; 
    $nick1 = hex2str($_GET['friendadded']); 
    $nick2 = hex2str($_GET['alreadyfriends']); 
    $nick3 = hex2str($_GET['alreadyinvited']); 
    if ($nick1) {
    $friendadded = "yes";
    } else if ($nick2) {
    $alreadyfriends = "yes";
    } else if ($nick3) {
    $alreadyinvited = "yes";
    }
    
    if ($mode == "editprofile") { ?>
    <script language=javascript>
    window.location="editaccount.php" + location.search;
    </script>
    <? } ?>
    
    <?
    $result1 = mysql_query("SELECT * FROM users WHERE email = '" . $_SESSION['email'] . "'", $database->connection);
    if(mysql_num_rows($result1) > 0) {
    $username = mysql_result($result1,0,"username");
    }
    if ($user_image) { 
    $imgtxt = "members/" . $user_image . ""; 
    }
    ?>
    <? 
    if ($_GET["epuid"] == "") { ?>
    
    <? } ?>
    
    <? 
    $email = $_SESSION['email'];
    $result = mysql_query("SELECT * FROM `privmsg` WHERE `to` = '" . $_SESSION['email'] . "' AND `read` = 0 ORDER BY timestamp DESC", $database->connection); 
    $inbox = mysql_num_rows($result);
    ?>
          <? if ($_GET["epuid"]) {
    $profile_nickname = hex2str($_GET["epuid"]);
    
    $result15 = mysql_query("SELECT * FROM users WHERE username = '" . $profile_nickname . "'", $database->connection);
    }
    if (mysql_num_rows($result15) == "0" || !$_GET["epuid"]) { ?>
    only the header has the session.php include

    thank you for replys

  4. #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    What's in session.php?

  5. #5
    New Coder
    Join Date
    Feb 2011
    Posts
    75
    Thanks
    9
    Thanked 2 Times in 2 Posts
    The is the whole session.php is attach to the session.txt

    Thank you for replys
    Attached Files Attached Files

  6. #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    So header.php includes session.php, and nothing else?
    What of these, do any of these include session.php or header.php?
    PHP Code:
    include("database.php");
    include(
    "mailer.php");
    include(
    "form.php"); 
    The easiest fix is to simply use _once functions on the include/requires. No matter where its from, this file has been included more than once.
    You should consider upgrading this code from 4.x compatible OO to 5.x OO as well.

  7. Users who have thanked Fou-Lu for this post:

    Whatnot (05-10-2012)

  8. #7
    New Coder
    Join Date
    Feb 2011
    Posts
    75
    Thanks
    9
    Thanked 2 Times in 2 Posts
    thank you the include once works


 

Posting Permissions

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