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>

Link to comment
Share on other sites

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'] );

???

Link to comment
Share on other sites

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']}'");

Link to comment
Share on other sites

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. =/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.