I want to get the last insert id from table, Iam using MAX(user_id),but its not working (column \[code\]user_id\[/code\] is an auto_increment field) here is my codeclass.php\[code\]<?phpclass Chat extends Core { public function addUser($email) { $this->query("INSERT INTO `users`(`username`) VALUES ('" . $this->db->real_escape_string($email) . "') "); $q = "select MAX(user_id) from `users`"; $result = mysql_query($q); $data = http://stackoverflow.com/questions/15740020/mysql_fetch_array($result); }}}?>\[/code\]when i am running this query i got an warning message like this\[quote\] Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource\[/quote\]can anybody help me...thanks.