Hiii every one i'm trying to count the impression of the specific image once in 24hr.
here is the code
<?php require_once '../dbconfig.php'; $mid = $_REQUEST['id']; <------------------------- Image Id $ip = $_SERVER['HTTP_HOST'];<------------------------- Viewers ip $date = date("Y-m-d");<------------------------- current date $qh = mysql_query("SELECT date,ip FROM image_hits WHERE image_id='$mid'") or die(mysql_error()); <------------------------- It will check whether any rows using that image id is present or not... if not it will produce "0" while($a = mysql_fetch_array($qh)){ $date1 = $a['date']; $ip1 = $a['ip']; } if(($ip==$ip1) && ($date==$date1)){<------------------------- Checking current date with the database values $h = mysql_query("SELECT visits FROM image_hits WHERE image_id='$mid'") or die(mysql_error()); while($b = mysql_fetch_array($h)){ $visits = $b['visits']; } echo $visits; } else { <----------------------- it will select the current values and will increment it by 1 and ten insert into database... $qh1 = mysql_query("SELECT visits FROM image_hits") or die(mysql_error()); while($c = mysql_fetch_array($qh1)){ $visits1 = $c['visits']; } $visits2 = $visits1+1; $hits = mysql_query("UPDATE image_hits SET visits='$visits2' WHERE date='$date' AND ip='$ip'") or die(mysql_error()); while($d = mysql_fetch_array($hits)){<-------------------------the error shows... $visits = $d['visits']; } echo $visits1; } ?>
The warning message is hsown below
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Mobitalk.com\members\image_hits.php on line 25
Any help will greatly appreciated....
If there is any easier way to do then plz recommend...
Thank You....