I am just trying to get the auto incremented value of a table that is currently the highest. I do not need to know what the next auto increment is, just the highest value of what is in the table right now. I am using the code below, but regardless of what the actual auto increment is, what table I last inserted into, what table was last updated / modified, or any other factors that I can see, the value always returns
Resource id #4
<?php $highest_id = mysql_query("SELECT MAX(c_id) FROM customers"); ?>
mysql_query doesn't return the value from the query, it returns a result resource. To get the actual value, you need to use one of the
mysql_fetch_* functions, passing it the result resource you got from
<?php $result = mysql_query("SELECT MAX(c_id) FROM customers"); $row = mysql_fetch_row($result); $highest_id = $row; ?>
or the shorter...
<?php $highest_id = mysql_result(mysql_query("SELECT MAX(c_id) FROM customers"), 0); ?>