thefollower Posted October 12, 2007 Share Posted October 12, 2007 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 More sharing options...
marcus Posted October 12, 2007 Share Posted October 12, 2007 $sql = "SELECT * FROM `table` WHERE `this`='that'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ $bounce = 1; } if($bounce === 1){ header("Location: thisorthat.php"); }else { $row = mysql_fetch_assoc($res); //etc... } Link to comment https://forums.phpfreaks.com/topic/72980-query-fetch-row/#findComment-368037 Share on other sites More sharing options...
thefollower Posted October 12, 2007 Author Share Posted October 12, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.