mattm1712 Posted December 15, 2010 Share Posted December 15, 2010 $last = mysql_query("SELECT MAX('id') FROM comments WHERE submittedby='$username'"); can any1 help me? Link to comment https://forums.phpfreaks.com/topic/221695-not-sure-why-this-wont-work/ Share on other sites More sharing options...
.josh Posted December 15, 2010 Share Posted December 15, 2010 be more specific than "it doesn't work". post errors, what it is supposed to be doing, what it is (not) doing. Link to comment https://forums.phpfreaks.com/topic/221695-not-sure-why-this-wont-work/#findComment-1147443 Share on other sites More sharing options...
mattm1712 Posted December 15, 2010 Author Share Posted December 15, 2010 im trying to select the latest post posted by eaach member on my site, the database is layed out in the umage attached, [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/221695-not-sure-why-this-wont-work/#findComment-1147447 Share on other sites More sharing options...
mattm1712 Posted December 15, 2010 Author Share Posted December 15, 2010 this is the full code i have $username = $_SESSION['user']; $last = mysql_query("SELECT MAX(id) FROM comments WHERE submittedby='$username'"); $lastdate = mysql_fetch_assoc($last); $ld= $lastdate['date']; echo $ld; Link to comment https://forums.phpfreaks.com/topic/221695-not-sure-why-this-wont-work/#findComment-1147455 Share on other sites More sharing options...
.josh Posted December 15, 2010 Share Posted December 15, 2010 well if that's your full code, then your first problem is that you aren't connecting to your database. Your 2nd problem is you don't have session_start. Link to comment https://forums.phpfreaks.com/topic/221695-not-sure-why-this-wont-work/#findComment-1147489 Share on other sites More sharing options...
MMDE Posted December 15, 2010 Share Posted December 15, 2010 As Crayon says, you need to connect to mysql first and select database. From what I can see of this script, it seems like you want the "last"/"highest" id number... may I ask why? because if it is so that you are going to insert a new user after this with 1 id higher than the current max, then I rather suggest you just set the column in mysql to auto increase and primary. Link to comment https://forums.phpfreaks.com/topic/221695-not-sure-why-this-wont-work/#findComment-1147499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.