Welcome Guest, Not a member yet? Register   Sign In
page gets loaded twice
#11

[eluser]InsiteFX[/eluser]
Code:
function inc_article_view($id)
{
    $this->db->query("UPDATE article SET views=views+1 WHERE id=?", array($id));

    // Test to see what your query is producing!
    echo $this->db->last_query();
    exit;
}

// or try this
function inc_article_view($id)
{
    $sql = "UPDATE article SET views=views+1 WHERE id=?";
    $this->db->query($sql, array($id));

    // Test to see what your query is producing!
    echo $this->db->last_query();
    exit;
}
#12

[eluser]tommebasso[/eluser]
i had to abandon my project for a while, and now i'm rewriting it from scratch. and while doing so i probably came to the solution to my problem.

in the header part of my site i have these two lines:

Code:
<base href="<?=base_url()?>" />
<link rel="shortcut icon" href="favicon.ico" />

it seems that the reference to the favicon gets handled somehow by the codeigniter app which causes the extra logs. i don't have any clue how that happens (i don't have fancy routings in my app config nor on the server).
all i can say is that since i changed the reference line to

Code:
<link rel="shortcut icon" href="<?=base_url()?>favicon.ico" />

there's no more double logging...

so, it seems resolved, but may be someone can enlighten me why this happens?
#13

[eluser]CroNiX[/eluser]
Are you using an htaccess? If you are this is a common problem when people don't tell it to NOT pass actual files/directories to CI (index.php) to be processed by CI, so it's probably trying to process all requests.

Here's one that I use a lot:
Code:
RewriteEngine On
#if the request is NOT a real file on the filesystem
RewriteCond %{REQUEST_FILENAME} !-f
#if the request is NOT a real directory on the filesystem
RewriteCond %{REQUEST_FILENAME} !-d
#then process it with CodeIgniter
RewriteRule ^(.*)$ index.php/$1 [L]
#14

[eluser]coolfactor[/eluser]
Make sure you don't have any "empty" <img> tags that would result in another page load when the browser tries to load that image. The favicon request that some browsers make (ie. Safari) also can trigger another page load. Just add an empty favicon.ico file to your webroot to prevent this possible cause.

If your HTML contains this, it would cause the page you're on to load a second time.
Code:
<img src="">




Theme © iAndrew 2016 - Forum software by © MyBB