Jump to content

[SOLVED] variables have no values when echo'd


thefollower

Recommended Posts

Try this, if fails uncomment debug section

 

<?php
include("include.php");

$GetLetters = mysql_query("SELECT * FROM messages WHERE Reciever='{$_SESSION['Current_User']}'") or die(mysql_error());

$row = mysql_fetch_assoc($GetLetters);//Moved for own formatting reasons
if (!$row)
{
header("Location: letterbox.php");
die;
}else{
$Subject = $row['Subject'];
$From = $row['Sender'];
$SentOn = $row['Senttime'];
$MessageOne = $row['MessageText'];
include("energybarinclude.php"); //Moved down (incase it un/sets $row)

//DEBUGING Uncomment the 2 lines below if this fails
#echo "MessageOne=$MessageOne<br>";//can remove this
#print_r($row);//can remove this, 

$FindUser1 = mysql_query("SELECT * FROM userregistration WHERE UserID='$From'") or die(mysql_error());
//Fetch the row from the database
$rowuser = mysql_fetch_assoc($FindUser1);

$UserName1 = $rowuser['UserName'];
}
?>
<div id="bv_" style="position:absolute;left:375px;top:468px;width:224px;height:128px;z-index:19" align="center">
<font style="font-size:13px" color="#000000" face="Arial"><?= $MessageOne ?></font></div>
<div id="bv_" style="position:absolute;left:182px;top:465px;width:150px;height:16px;z-index:22" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial">Message:</font>
</br>
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Subject: <?= $Subject ?><br>
<br><br>
From: <?=$From?>
<br>
Sent On:</br><?=$SentOn?>
<br>
<br>
Reply!</b></font></div></body>
</html>

Remember that $_SESSION is superglobal, and can be read in all the script, but will not be worth anyhting in query. Thus not returning anything for that user, but will still echo by itself in the script. Have you tried this:

$GetLetters = mysql_query("SELECT * FROM messages WHERE reciever=".$_SESSION['Current_User'] );

???

Remember that $_SESSION is superglobal, and can be read in all the script, but will not be worth anyhting in query. Thus not returning anything for that user, but will still echo by itself in the script.

 

What? That is no different to....

 

$GetLetters = mysql_query("SELECT * FROM messages WHERE Reciever='{$_SESSION['Current_User']}'");

Try this, if fails uncomment debug section

 

<?php
include("include.php");

$GetLetters = mysql_query("SELECT * FROM messages WHERE Reciever='{$_SESSION['Current_User']}'") or die(mysql_error());

$row = mysql_fetch_assoc($GetLetters);//Moved for own formatting reasons
if (!$row)
{
header("Location: letterbox.php");
die;
}else{
$Subject = $row['Subject'];
$From = $row['Sender'];
$SentOn = $row['Senttime'];
$MessageOne = $row['MessageText'];
include("energybarinclude.php"); //Moved down (incase it un/sets $row)

//DEBUGING Uncomment the 2 lines below if this fails
#echo "MessageOne=$MessageOne<br>";//can remove this
#print_r($row);//can remove this, 

$FindUser1 = mysql_query("SELECT * FROM userregistration WHERE UserID='$From'") or die(mysql_error());
//Fetch the row from the database
$rowuser = mysql_fetch_assoc($FindUser1);

$UserName1 = $rowuser['UserName'];
}
?>
<div id="bv_" style="position:absolute;left:375px;top:468px;width:224px;height:128px;z-index:19" align="center">
<font style="font-size:13px" color="#000000" face="Arial"><?= $MessageOne ?></font></div>
<div id="bv_" style="position:absolute;left:182px;top:465px;width:150px;height:16px;z-index:22" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial">Message:</font>
</br>
<font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Subject: <?= $Subject ?><br>
<br><br>
From: <?=$From?>
<br>
Sent On:</br><?=$SentOn?>
<br>
<br>
Reply!</b></font></div></body>
</html>

 

 

50% of that works but the Username part does not...

 

$FindUser1 = mysql_query("SELECT * FROM userregistration WHERE UserID='$From'") or die(mysql_error());
//Fetch the row from the database
$rowuser = mysql_fetch_assoc($FindUser1);

$UserName1 = $rowuser['UserName'];

 

$From when echo'd contains a number which is correct and that is the sender's ID so now its just something to do with this small part of the script .. were nearly there :D

 

No error occurs by the way. =/

i think it does if you add, to the start

 

<?php
// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>

 

anyways.. is that solved ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.