page view count increaes by two each time its loaded - php

Here is my php code:
#mysql_query("UPDATE mp3 SET views = views+1 WHERE id = '".mysql_real_escape_string($id)."'");
I have that in my header with some other PHP, every time I load the page, the view count goes up by 2 instead of one, what would be the cause of this? I checked the script over and everything looks fine. Thank you.

Check your CSS file or section for a URL background that is empty. That is the most common quirk that produces a double-retrieval.
Failing that, have a look in Firefox-Firebug / Chrome developer tools or something similar for which part of the code is causing the page to be loaded twice each time

Related

Load entire html file to parse with php?

i try to parse a website's html file with php fopen(). Thats works so far very well but the problem is, that there are serveral posts on the site that aren't shown in the html file, because u have to scroll far down until the posts load.
As an example, i try to count the total amount of comments in my own facebook page. (Just an example, if it's shown somewhere on facebook, that doesn't help me)
How can I make the html file load completely?
Thank you
you cannot, directly. What you are doing is called scraping. You have to inspect the queries made by the browser in your developer tools when viewing that page yourself, and reproduce those queries in php through fopen() or any other means (CUrl, etc...)

PHP+Kendo Grid ServerPaging first Page lists all entries

I've got a working kendo grid with remote data from the webserver.
But the paging isn't working as expected. If the page gets loaded the first time, or I click on page 1 the server returns all the data available.
If I click on page 2 oder every other page than the first one it works fine.
The query seems to be correct as you can see in the screenshot from firebug.
So anyone got a hint for me where to look at?
Just found the problem. I was removing empty parameters on the serverside. So I was throughing away the "skip" which screwed the query up.

Magento PHP pages not refreshing

I'm using Magento to build our EC site.
And I found our product page is not refreshing when I enable "Full Page Cache".
For example, I do this in the first line:
echo time();
but it always shows the same timestamp no matter how many time I refresh the browser.
(And I already disable the cache function in my browser)
But the funny thing is when I append any parameter to my url,
for example
mysite/?a=0
The timestamp is updated accordingly.
Is this the expected scenario with Magento framework?
Or did I just get something wrong?
Thanks.
That's right!
You need to develop a store without cache function.
At the end you can turn it on. This cache is intended to user

Controller action called twice

I am developing an web app with Laravel and I encountered this "strange" behavior. Some controller actions are called twice. I know so because on my logs I see (for one page refresh) two full sets of entries. My controller action starts like this:
public function action_edit($rid=-1) {
// Calc Input
$id = Input::get('id', $rid);
Log::TWICE("?? {$id} - {$rid}");
where $rid is the object id to edit as requested by the url, however if I get an id in my Input, then I use this id instead. So when I call my controller via a url like:
.../mycontroller/edit/1
I get TWO entries in my log file:
2013-02-07 00:49:15 TWICE - ?? 1 - 1
2013-02-07 00:49:16 TWICE - ?? img - img
The first one is the normal that I should see, however the second one I don't understand where it is coming from. I checked using the Chrome's developer tools (both network tab and console tab) but there is no sign of the second request!! I initially thought that I might try to use some resource with a relative url of img or ../img but I found no clue. Of course img is the name of my images folder on my template but there is nowhere in my code a relative url img by itself...
Do you have any suggestions regarding this issue? Where else in my code should I examine/check? What else could trigger the second call?
NOTE: I am using the following call at some point on my code but the referenced action is 'show' not 'edit'!!
Laravel\Routing\Controller::call($controller.'#show', ...
Thank you in advance!
Pan
This is probably the browser trying to request a Favicon.
Try with curl and you most likely won't see the request.
I had a similar problem, and the cause was a Trend Micro Firewall we were behind.
The datacenter was crawling every URL submitted, causing it to be hit twice.
This post has more information
http://community.trendmicro.com/t5/Worry-Free-Business-Security/WFBS-Trend-Micro-sending-our-data-from-an-IP-in-Tokyo/td-p/15600
I spoke to our web admin who said he would exclude the site from TrendMicros link site check
This is an old question, but I still see this at the top of the Google result when I search for solution, so I decided to add this answer after I finally find the problem.
The current answer that marked as correct is only partially correct: it is related to image, but it is not limited to Favicon.
Somehow all major browser (at least for IE, Firefox and Chrome) decide that when there is an empty link provided to whatever place that is supposed to be an image, they will make it the current URL. Some example of places that may cause problem:
<img src="">
<div class="background-image:url()"></div>
<link rel="icon" type="image/x-icon" href="">
Provide a link or simply remove the line will solve the problem.

Problem with page loading content, inside content

if you visit here: Example You will see my problem.
The page loads, then loads all the same content within a div id=content
Have a look at the source for the JS/jQuery and if you need the PHP just let me know. Im not too sure if its the JS or PHP that's doing this. I use the jQuery Address Plugin so maybe im not using it properly but this is killing me.
any ideas on what i could be doing wrong? in Firebug the page loads and simply doesn't stop. Try it out if you have it.
Any help is appreciated!!
This line of code:
$('.content').load('http://laynestaley.co.uk/test/'+fragment+'?ajax=1');
Is actually loading the entire page into <div class='content'></div>. Your server-side code must not be executing the way you expect it to with that AJAX call (It's just loading the index page of /test/ again).
I agree with #Andrew, but just a suggestion -- if you don't want the page to "snap" when the AJAX is loaded, set your height in css to something like 100%
You are incorrectly building fragment. In you code first letter truncated in query.
Correct code:
fragment = event.value.substring(2);

Categories