FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
Code problem
Message  

Reply with quote
Post Code problem 
I have a few problems with my code,

Its meant to load 3 messages i would use a while loop but that is beyond my skill level so for now im using a really bad method but it should work none the less... and half of it does but the other won't.

I have 2 messages in the database and my code is only loading the 2nd message but not the first even though it should be loading the first message in the database if the 2nd one is loading ....
Also one other small problem is the for message 2 username doesn't load up...im not sure what to do from here... any help is much appreciated:

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

$GetLetters = mysql_query("SELECT * FROM messages WHERE reciever='$_SESSION[Current_User]'");
if (!($row = mysql_fetch_assoc($GetLetters))) {
   header("Location: letterbox.php");
   die;
}
Else{
include("energybarinclude.php");
$Subject = $row['Subject'];
$From = $row['Sender'];
$SentOn = $row['Senttime'];
$MessageOne = $row['MessageText'];

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

$UserName1 = $rowuser['UserName'];

$rowtwo = mysql_fetch_assoc($GetLetters);
$Subjecttwo = $rowtwo['Subject'];
$Fromtwo = $rowtwo['Sender'];
$SentOntwo = $rowtwo['Senttime'];
$MessageTwo = $rowtwo['MessageText'];
$FindUser2 = mysql_query("SELECT * FROM userregistration WHERE UserID='$Fromtwo'");
// Fetch the row from the database
$row2 = mysql_fetch_assoc($FindUser2);

$UserName2 = $row2['UserName'];
?>


View user's profile Send private message

Reply with quote
Post  
I will suggest you one thing, that I always suggest to everyone: USE SINGLE QUOTES FOR STRINGS. Otherwise you will always have errors like this. This should be working:

Code:

<?
include("include.php");

$GetLetters = mysql_query('SELECT * FROM messages WHERE reciever=\''.$_SESSION[Current_User].'\'');
if (!($row = mysql_fetch_assoc($GetLetters))) {
   header("Location: letterbox.php");
   die;
}
else{
include("energybarinclude.php");
$Subject = $row['Subject'];
$From = $row['Sender'];
$SentOn = $row['Senttime'];
$MessageOne = $row['MessageText'];

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

$UserName1 = $rowuser['UserName'];

$rowtwo = mysql_fetch_assoc($GetLetters);
$Subjecttwo = $rowtwo['Subject'];
$Fromtwo = $rowtwo['Sender'];
$SentOntwo = $rowtwo['Senttime'];
$MessageTwo = $rowtwo['MessageText'];
$FindUser2 = mysql_query("SELECT * FROM userregistration WHERE UserID='$Fromtwo'");
// Fetch the row from the database
$row2 = mysql_fetch_assoc($FindUser2);

$UserName2 = $row2['UserName'];
?>



_________________
www.eb-downloads.com
FREE E-BOOKS DOWNLOADS.
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com