oracle765 Posted October 17, 2014 Share Posted October 17, 2014 http://www.compareandchoose.com.au/video_games?shopingfor=US&shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=AU&shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=UK&shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=US&shopingfor=UK http://www.compareandchoose.com.au/video_games?shopingfor=AU&shopingfor=UK http://www.compareandchoose.com.au/video_games?shopingfor=UK&shopingfor=UK http://www.compareandchoose.com.au/video_games?shopingfor=US&shopingfor=AU http://www.compareandchoose.com.au/video_games?shopingfor=AU&shopingfor=AU http://www.compareandchoose.com.au/video_games?shopingfor=UK&shopingfor=AU when it should only show http://www.compareandchoose.com.au/video_games?shopingfor=US http://www.compareandchoose.com.au/video_games?shopingfor=AU http://www.compareandchoose.com.au/video_games?shopingfor=UK why its appending all combinations I am not sure Please find my 3 page code files it uses Hi Professionals I have been doing a site check with MOZ tools and it is showing duplicate page content for all my shopping pages Basically I have a site where you can compare products for either the UK,US or AU But it is showing the above results in MOZ I have tried everything to figure this out, but because it was not written by me I cannot pin point it Please find attached the 3 pages it utilises check_form.php shopping_video_games.php video_games.php Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 17, 2014 Share Posted October 17, 2014 So - while doing your debugging (you did do that, right?) which of those scripts seems to be doing the posting work? Isolate the part of your code(s) to where the output is being created and then add some echos to help you see what it is doing and then you may see where it is going wrong. If not, then show us THAT part of the code with some explanation of what is supposed to be doing. Some of us don't open people's attachments. Phobias. Quote Link to comment Share on other sites More sharing options...
oracle765 Posted October 18, 2014 Author Share Posted October 18, 2014 lol don't blame your phobia I don't know which piece fo code it is I am not to good with php but basically its adding ?shoppingfor=UK&shoppingfor=AU when it should only be ?shoppingfor=UK I don't know why its appending all combinations Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 18, 2014 Share Posted October 18, 2014 it would help if you told us what exactly you did that resulted in that output, what moz tool and what url you fed it that led up to that list of links, i.e. provide some context and a starting place. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 18, 2014 Share Posted October 18, 2014 i can tell you why the two shopingfor get parameters get put into the url. whomever did write this code ASSUMEd (i.e. to make an ASS out of U and ME - i.e. him) that if here is a shopingfor in the url that it will always be &shopingfor. that's not always the case, because there won't be an &shopingfor when shopingfor is the first or only get parameter. except of course that the kid who did write this code formed some urls like - video_games?&shopingfor=US i'm going to guess whatever moz tool you used either correctly formed the urls (without the ?& business) or you fed the tool a correct url (without the ?& business), in which case the php code couldn't find the (in)correct part it was looking for and appended a second shopingfor get parameter. all of the get parameter handling in the php code is bogus (edit, if you pick a country flag, then do a search, you loose the country selection in the url as well, so the problem goes well beyond just the code you have posted.) the correct way would be to get the get parameters into an array, such as the $_GET array, set the specific one you want to the value you want, then use a php function like http_build_query() when forming the urls. Quote Link to comment Share on other sites More sharing options...
oracle765 Posted November 15, 2014 Author Share Posted November 15, 2014 thanks for this mac_giver but to be honest I got this done offshore and I would not know where to start, if anyone is skilled enough to do some freelance work I would be happy to arrange something thanks Quote Link to comment Share on other sites More sharing options...
Csharp Posted November 16, 2014 Share Posted November 16, 2014 thanks for this mac_giver but to be honest I got this done offshore and I would not know where to start, if anyone is skilled enough to do some freelance work I would be happy to arrange something thanks This is usually the kind of stuff that happens when you send something offshore. It works badly and usually the people responsible for it don't feel responsible after doing it. Let me explain your issues here (since there is always 2 with this kind of bugs): The code is somewhere generating an URL that is broken (like mac_gyver said - he's response is totally valid) The code does not correctly detect the broken URLs and redirect them. A well written application would have noticed and issued a corrected canonical URL or a 301 redirect when somebody accesses the page with such an obviously incorrect URI. You should use some kind of system that filters unused parameters out anyway in order to avoid to get duplicate content issues EVERYWHERE. Quote Link to comment Share on other sites More sharing options...
oracle765 Posted November 18, 2014 Author Share Posted November 18, 2014 Hi Csharp I am looking into this, thanks all for the replies Quote Link to comment Share on other sites More sharing options...
oracle765 Posted December 14, 2014 Author Share Posted December 14, 2014 hi again. Its been a few weeks now and I still cannot figure this out to be honest, is there any freelancers out there who could tackle this for me thanks in advance Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 14, 2014 Share Posted December 14, 2014 this is mostly going to be negative commentary, based on what i can recall from looking at the specific code in this thread (that was months ago), your site, and past threads (even longer ago.) you have a huge amount of hard-coded logic, for what is essentially a content management system. the programmers made only a little use of any sort of functions/classes/organization/framework. each page on your site only differs in the category of content on the page. this all could have and should have been handled using general purpose code on one physical page, with url rewriting to produce logical pages for each category. i don't recall, but i'm betting that even the navigation is hard-code, rather than database driven. for the shopping page that's the subject of this thread, the problem is because whoever wrote the code, hard-coded the logic building the urls to be specific to what the page is doing, so any variation or change to what the page does, which i suspect is where the three country flag selections come in to this problem, requires going through all the code that's relevant to that page to alter each instance where it uses or builds the get parameters in the urls. this would include both the code where the form is displayed and the search result page. i can recall that the code is using both url and session variables, meaning that the code must keep track of two different sources of same meaning information. i mentioned above in this thread using http_build_query() to handle making the url's with any existing get parameters and only modifying the one(s) that any section of code needs to change. unfortunately, making this change to the code would require going though all the relevant code to determining what it is doing (i.e. finding every place that's using or producing get parameters in the urls and in the session variables), modifying, and then testing it to make sure that it works properly. this is more than changing a couple of lines of code. p.s. i just tried a search on the insurance page and got a php error displayed - Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ... there's three problems with this - 1) you should not be displaying php errors to the visitors, you should be logging php errors, 2) the code should have detected the query that failed with an error, logged the actual information about the error, displayed a harmless message to the visitor, and prevented the remaining code from running and throwing follow-on errors, and 3) you should not be using the obsolete mysql_ functions. you should be using either the mysqli_ or PDO functions. had this code been written in an organized way, to switch to the newer database functions should only require replacing the code in the database layer, not going through every piece of code and changing functions. short-answer: the army of coders that typed this code up for you didn't have any experience at actually coding a web page or were intentionally making it so that you would need to pay them more to fix or change the code or face having someone else doing a greater amount of work to fix or change anything than what it would take to just start over with a proper design. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 14, 2014 Share Posted December 14, 2014 here's some information for using the php http_build_query() function. the input values your page(s) receive determine what will be displayed (gotten) on that page and should be in the form of $_GET parameters that your php code receives, either directly or as the result of a 'pretty' url being rewritten to the actual url that your script gets requested by. everything from your categories, subcategories, country flag (and i noticed some country drop-downs on your site) selection, and any actual search terms that get submitted are all just filters that determine what to query for and display on the ONE page (there's no actual good reason to have separate search pages and result pages as it results in more code that must be written, tested, and paid for.) except for the cases where you intentionally reset a filter (such as going back to page 1 in pagination when you alter/submit new values for any of the other filters) each different piece of code that produces links or a form for one of these filters should simply take the existing $_GET array, modify the value(s) it is responsible for, then use the combined resulting array to build links or hidden fields in a forms. building links is where using http_build_query() comes in. it takes an input array and produces the query string part of a link. if you are instead using 'pretty' rewritten urls, you would take the combined resulting array and pass it through your function that knows how to make the pretty urls from the component parts. if you search phpfreak's for http_build_query, any of the posts by badge'd members will show how to take the existing $_GET array, modify just the element(s) any particular piece of code is responsible for, then build the query string portion of the links. Quote Link to comment 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.