evanct Posted May 21, 2009 Share Posted May 21, 2009 This: $sql="SELECT MAX(session_id) FROM sessions"; echo dbQuery($sql); prints 1. Even though the greatest session_id value is 9. It doesn't matter what type of values the field has - integers, timestamps, strings, whatever - SELECT MAX() always returns 1. Is there something I'm missing here? Link to comment https://forums.phpfreaks.com/topic/159027-solved-max-returns-1/ Share on other sites More sharing options...
Ken2k7 Posted May 21, 2009 Share Posted May 21, 2009 I think your function dbQuery() returns true and echo outputs 1. Do you have a function that grabs a mysql result? Like dbResult or something? Link to comment https://forums.phpfreaks.com/topic/159027-solved-max-returns-1/#findComment-838659 Share on other sites More sharing options...
mmarif4u Posted May 21, 2009 Share Posted May 21, 2009 It will print 1, because you are printing sql result, not query result. You have to echo your row result like: $sql="SELECT MAX(session_id) FROM sessions"; $q=mysql_query($sql); $row= mysql_fetch_array($q); echo $row['MAX(session_id)']; Hope, it make sense. Link to comment https://forums.phpfreaks.com/topic/159027-solved-max-returns-1/#findComment-838661 Share on other sites More sharing options...
evanct Posted May 21, 2009 Author Share Posted May 21, 2009 Oh that did it mmarif4u. Now i'm having a noob moment. but thanks. Link to comment https://forums.phpfreaks.com/topic/159027-solved-max-returns-1/#findComment-838665 Share on other sites More sharing options...
mmarif4u Posted May 21, 2009 Share Posted May 21, 2009 You are most welcome. Link to comment https://forums.phpfreaks.com/topic/159027-solved-max-returns-1/#findComment-838667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.