You have a problem that mysql_fetch_array () takes the first resource parameter generated by mysql_query, and you pass it a string.
Please stop using the mysql extension ... It is outdated and not supported, it is insecure due to the lack of placeholders.
Use Mysqli or PDO, which in the latter case allows you to implement the OOP approach.
$dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $opt = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $pdo = new PDO($dsn, $user, $pass, $opt); $query="SELECT id,z,i,count FROM log ORDER BY id DESC limit 1"; $stm = $pdo->query($sql); $result = $stm->fetch(PDO::FETCH_OBJ); echo $result->count;