I am getting the Resource id #3 error when I am trying to echo out the value of the column counter from the database. I want to get a single value only. Any ideas how can I do that ?
$Page = $_SERVER['PHP_SELF'];
$num = preg_replace("/[^0-9]/", '', $Page);
$query = "SELECT * FROM hitscounter WHERE page='$num';";
$res = mysql_query($query);
if (mysql_num_rows($res) > 0) {
mysql_query("UPDATE hitscounter SET counter=counter+1 Where page='$num'");
$views = mysql_query("SELECT counter FROM hitscounter WHERE page=555");
mysql_fetch_array($views, MYSQL_NUM);
mysql_free_result($views);
echo $views;
}
you should use the
resultyou get back frommysql_fetch_array, just like this: