Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:33:28+00:00 2026-06-07T22:33:28+00:00

I am using Smarty with this settings: $smarty = new Smarty; $smarty -> caching

  • 0

I am using Smarty with this settings:

$smarty = new Smarty;
$smarty -> caching =3600;
$smarty -> compile_check =true;
$smarty -> compile_dir = 'theme/compile/';
$smarty -> config_dir = 'theme/libs/';
$smarty -> cache_dir = 'theme/cache/';
$smarty -> plugins_dir = 'theme/libs/plugins/';
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
$smarty -> clear_compiled_tpl();

I want to program a simple visitors counter with this function :

function counter() {
    $ip = $_SERVER['REMOTE_ADDR'];
    $now = time();
    $y1 = jgmdate("Y ", $now);
    $y1 = (int) $y1;
    $m1 = jgmdate("m", $now);
    $m1 = (int) $m1;
    $d1 = jgmdate("d", $now);
    $d1 = (int) $d1;

    $result3 = mysql_query("SELECT `times`,`id` FROM `stat_ip` where `IP`='$ip' AND   `year`='$y1' AND `month`='$m1' AND `day`='$d1' ;");
    unset($n3);
    $n3 = (int) mysql_num_rows($result3);
    echo $n3;
    if ($n3 == 0) {
        mysql_query("INSERT INTO `stat_ip` (`id` ,`IP` ,`year` ,`month` ,`day`) VALUES (NULL , '$ip', '$y1', '$m1', '$d1') ;");
    } else if ($n3 == 1) {
        $row3 = mysql_fetch_array($result3);
        $s = (int) $row3['times'] + 1;
        mysql_query("UPDATE `stat_ip` SET `times` = '$s' WHERE `id` = '".$row3['id']."' ;");

    } else {
        echo("error");
    }
}

everything is ok , but my query executes more than a time in this line(Probably all queries) :

mysql_query("UPDATE `stat_ip` SET `times` = '$s' WHERE `id` = '".$row3['id']."' ;") ;

I think smarty has something to do with my problem!

when I write this code :

$q=$smarty -> fetch('index.tpl');

the query executes 1 time however when I change my code to :

$q=$smarty -> fetch('index.tpl');
echo $q;

or

$smarty -> display('index.tpl');

my queries execute more than one time!:(

for more information:

http://www.smarty.net/forums/viewtopic.php?p=81161

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:33:30+00:00Added an answer on June 7, 2026 at 10:33 pm

    A Common mistake is to have an empty img-tag or script-tag in your html output – this makes the browser re-request the current page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Code Igniter, The HMVC library , and Smarty with this library
I am using {foreach} within smarty like this {foreach key=num item=reply from=$replies} //something goes
Hey guys, I'm using smarty and php I am trying to make this function
I'm using Smarty and utilizing the config_load respective {#VAR#} variables to implement localization. This
How should I avoid using the this pointer in conjunction with smart pointers? Are
I found that using Smarty with PHP, sometimes extra time will need to be
I'm using Smarty templates which call object methods. I've put the code on a
I'm using smarty for my site, and I'm trying to loop through an array
I am using smarty tags with php and my question / issue is regarding
I am using CI + smarty + dojo framework in my one application. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.