Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-09-2012, 01:46 PM   PM User | #1
Whatnot
New Coder

 
Join Date: Feb 2011
Posts: 71
Thanks: 8
Thanked 2 Times in 2 Posts
Whatnot is an unknown quantity at this point
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
Whatnot is offline   Reply With Quote
Old 05-09-2012, 03:15 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Have you attempted to include this file twice?
Fou-Lu is offline   Reply With Quote
Old 05-10-2012, 10:00 AM   PM User | #3
Whatnot
New Coder

 
Join Date: Feb 2011
Posts: 71
Thanks: 8
Thanked 2 Times in 2 Posts
Whatnot is an unknown quantity at this point
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
Whatnot is offline   Reply With Quote
Old 05-10-2012, 02:45 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
What's in session.php?
Fou-Lu is offline   Reply With Quote
Old 05-10-2012, 06:03 PM   PM User | #5
Whatnot
New Coder

 
Join Date: Feb 2011
Posts: 71
Thanks: 8
Thanked 2 Times in 2 Posts
Whatnot is an unknown quantity at this point
The is the whole session.php is attach to the session.txt

Thank you for replys
Attached Files
File Type: txt session.txt (23.1 KB, 17 views)
Whatnot is offline   Reply With Quote
Old 05-10-2012, 06:43 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Whatnot (05-10-2012)
Old 05-10-2012, 08:38 PM   PM User | #7
Whatnot
New Coder

 
Join Date: Feb 2011
Posts: 71
Thanks: 8
Thanked 2 Times in 2 Posts
Whatnot is an unknown quantity at this point
thank you the include once works
Whatnot is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:06 PM.


Advertisement
Log in to turn off these ads.