Jump to content

query fetch row


thefollower

Recommended Posts

I have a code which checks if the row is not found but then i have another line to get the row that is found straight after... but for some odd reason say i have 2 rows in the database itll only show the second row... i was wondering if its because i have a fetch row twice as i will show below:

 

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


if (!($row = mysql_fetch_assoc($GetLetters))) {
    $bounce = 1;
}

If ($bounce == 1){

header("Location: letterbox.php");
}
else
{
include("energybarinclude.php");

$row = mysql_fetch_assoc($GetLetters);
$Subject = $row['Subject'];
$From = $row['Sender'];
$SentOn = $row['Senttime'];
$MessageOne = $row['MessageText'];

 

Also just to add if i blank out //$row = mysql_fetch_assoc($GetLetters);

for some reason it won't show row 1 when it should yet it shows row 2 when i do include $row = mysql_fetch_assoc($GetLetters);

How could this be, because row 1 is deffinatly visible in my database.

Link to comment
https://forums.phpfreaks.com/topic/72980-query-fetch-row/
Share on other sites

could you talk me through that i've not seen it written in that way before... just curious i like to understand it as much as get it working :)

 

Edit :

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #6' at line 1
Link to comment
https://forums.phpfreaks.com/topic/72980-query-fetch-row/#findComment-368039
Share on other sites

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.