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? Quote 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. Quote 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] Quote 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; Quote 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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.