alwaysme Posted December 30, 2007 Share Posted December 30, 2007 hi there, i have a script that increase views with IP ADDRESS...however i want it with a refresh.... my friend told me to do this change if(!isset($_COOKIE[$id])){ $twomonths = 60 * 60 * 24 * 60 + time(); setcookie("$id", $id, $twomonths); $viewaddone = true; } to if(!isset($_COOKIE[$id])){ $1sec = 1 + time(); setcookie("$id", $id, $1sec); $viewaddone = true; } but that give me error Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /home/public_html/multimedia/videos.php on line 13 anyone can help me please? Quote Link to comment https://forums.phpfreaks.com/topic/83711-solved-coockie-help-refresh/ Share on other sites More sharing options...
avo Posted December 30, 2007 Share Posted December 30, 2007 HI Noticed you have started a variable with a number not allowed try $onesec = 1 + time(); not $1sec = 1 + time(); Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/83711-solved-coockie-help-refresh/#findComment-425939 Share on other sites More sharing options...
alwaysme Posted December 30, 2007 Author Share Posted December 30, 2007 i get another error Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /home/public_html/multimedia/videos.php on line 14 this is the whole file <?php $id = $_GET["id"]; if(!isset($_COOKIE[$id])){ $onesec = 1 + time(); setcookie("$id", $id, $1sec); $viewaddone = true; } require('header.php'); if(isset($id)){ $result = mysql_query("SELECT * FROM pp_files WHERE id=$id LIMIT 1") or die(); }elseif (isset($_GET["name"])){ $name = $_GET["name"]; $result = mysql_query("SELECT * FROM pp_files WHERE `approved` = '1' AND `name` = '$name' LIMIT 1") or die(); }else{ $result = mysql_query("select * from pp_files WHERE approved='1' AND reject='0' order by rand() LIMIT 1") or die(); } // For each result that we got from the Database while ($row = mysql_fetch_assoc($result)) { $video[] = $row; if($viewaddone == true){ $new_views = $row["views"] + 1; mysql_query("UPDATE pp_files SET views = '$new_views' WHERE id = '$id'"); } $smarty->assign('vidtype', $row['video_type']); if( $row['video_type'] == "dailymotion"){ $dm_xml_pic_string = @file_get_contents("http://www.dailymotion.com/atom/fr/cluster/extreme/featured/video/".$row['file']); $dm_xml_pic_start = explode("/swf/",$dm_xml_pic_string,2); $dm_xml_pic_end = explode("\"",$dm_xml_pic_start[1],2); $dmid = $dm_xml_pic_end[0]; $smarty->assign('dmid', $dmid); } } // Assign this array to smarty $smarty->assign('video', $video); $smarty->assign('id', $row['id']); if(isset($_GET["pop"])){ $smarty->display('viewvidpop.tpl'); }else{ $smarty->display('viewvid.tpl'); } mysql_close($mysql_link); ?> what could have been fix,, ;[ Quote Link to comment https://forums.phpfreaks.com/topic/83711-solved-coockie-help-refresh/#findComment-425952 Share on other sites More sharing options...
avo Posted December 30, 2007 Share Posted December 30, 2007 Hi Change this line setcookie("$id", $id, $1sec); to setcookie("$id", $id, $onesec); Regards Quote Link to comment https://forums.phpfreaks.com/topic/83711-solved-coockie-help-refresh/#findComment-425955 Share on other sites More sharing options...
alwaysme Posted December 30, 2007 Author Share Posted December 30, 2007 the page laoded now and the view will not change at all this time maybe i have to change $twomonths somewhere else? where i go into the db maybe? i look in all suspect of files but i cannot find this word anywhere :-\ Quote Link to comment https://forums.phpfreaks.com/topic/83711-solved-coockie-help-refresh/#findComment-425964 Share on other sites More sharing options...
alwaysme Posted December 30, 2007 Author Share Posted December 30, 2007 maybe this file also responsible? <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Smarty {counter} function plugin * * Type: function<br> * Name: counter<br> * Purpose: print out a counter value * @author Monte Ohrt <monte at ohrt dot com> * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} * (Smarty online manual) * @param array parameters * @param Smarty * @return string|null */ function smarty_function_counter($params, &$smarty) { static $counters = array(); $name = (isset($params['name'])) ? $params['name'] : 'default'; if (!isset($counters[$name])) { $counters[$name] = array( 'start'=>1, 'skip'=>1, 'direction'=>'up', 'count'=>1 ); } $counter =& $counters[$name]; if (isset($params['start'])) { $counter['start'] = $counter['count'] = (int)$params['start']; } if (!empty($params['assign'])) { $counter['assign'] = $params['assign']; } if (isset($counter['assign'])) { $smarty->assign($counter['assign'], $counter['count']); } if (isset($params['print'])) { $print = (bool)$params['print']; } else { $print = empty($counter['assign']); } if ($print) { $retval = $counter['count']; } else { $retval = null; } if (isset($params['skip'])) { $counter['skip'] = $params['skip']; } if (isset($params['direction'])) { $counter['direction'] = $params['direction']; } if ($counter['direction'] == "down") $counter['count'] -= $counter['skip']; else $counter['count'] += $counter['skip']; return $retval; } /* vim: set expandtab: */ ?> ??? Quote Link to comment https://forums.phpfreaks.com/topic/83711-solved-coockie-help-refresh/#findComment-425965 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.