-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Command-line? $ php -r "var_dump(preg_match('/(?=.*\bdog\b)(?=.*\bpuppet\b)(?=.*\bfuzzy\b)/', 'need fuzzy hand puppet in dogpen for dog'));" int(1)It works.
-
Your query will return to you a single number that counts how many rows there are. Put another way, how do you expect COUNT() to work if the query has to return every single row?
-
-
Help understanding cookies, domains, and paths
requinix replied to NotionCommotion's topic in PHP Coding Help
An article about cookies tl;dr: - Cookie domain matches the tail end of the hostname - Cookie path matches the beginning of the path For rewriting, everything happens according to what the browser sees. It doesn't know (or care) about the fact that the URL is being rewritten somewhere else. -
It's not that simple. What type of applications? Employment in what field? Java is a little more flexible than C++ in that regard (at least not without using assorted frameworks) but people don't use it for "normal" programs anymore.
-
Why do you want to learn it? Java is more common for web development and helps for Android, C/C++ teaches you a lot about how software works at a lower level.
-
Use date_default_timezone_set to make sure your code is using the right timezone. Are you open to the idea of refactoring that code? To make it easier to maintain, read nicer, not have as much copy-and-paste... It wouldn't fix the problem but it would be a good thing to do if you have the time.
-
Have you already checked the time on the server?
-
So it always says that user/email in use message? That must mean if ( $test_test === NULL ) {was never true. Well, what is the value of $test_test? It comes from while ($test_test=$test->fetch()) {and $test came from $test = $bdd->prepare('SELECT pseudo FROM membres WHERE pseudo= ? OR email = ? ') ;That means $test is a PDOStatement object and $test->fetch is PDOStatement::fetch. If you look at the documentation you'll see that is says (in English), It never returns null. That's why $test_test === NULL is never true.
-
Confused about what, exactly? Seems fairly straightforward.
-
not sure if you'll get it. But it is very difficult.
requinix replied to lecestan96's topic in PHP Coding Help
Are you doing this in PHP or Java? Either way, post your code and describe what problems you're having with it. -
If they didn't tell you it's dedicated hosting, it's shared. [edit] Check __FILE__ or __DIR__: if they have your username in it, like /home/username, then it's shared. If you have virtually no control over the server, it's shared.
-
A lot of this depends on how the sitebuilder thing sets up the redirects. What do you know about that? Or maybe, what script thing are you using so we can find it ourselves?
-
Each will have a reason but many of them could be the same "problem" as those two: different query strings. You would have to look at each to decide whether the tool is wrong. Three basic outcomes for each: 1. The tool is wrong: the difference(s) in the query string affect what the page shows so there is no duplicate content 2. The tool is right: the difference(s) in the query string do not affect the page, one or both of the pages should be marked noindex because the content is irrelevant for SEO 3. The tool is right: the difference(s) in the query string do not affect the page, one of the pages should redirect to the other (if you want one URL to be "correct") or they both should indicate the canonical URL (if you don't want to redirect) categories.php falls under outcome 1, cart.php falls under outcome 2 or 3 (I'd go for 2 because the shopping cart page is meaningless in SEO). So the code. Canonical stuff looks like <link rel="canonical" href="http://www.example.com/path/to/canonical/page.php"> <link rel="canonical" href="http://forums.phpfreaks.com/topic/292324-help-with-fixing-my-seo-problems-on-a-php-site/">Goes in the .You should really put that on all your pages, not just ones that look like duplicates. Redirect stuff... is a bit trickier, if you deal with query strings. You can't just compare URLs (the actual vs the one you want) because the order of key/value pairs in the query string doesn't matter, and "a=1&b=2" should be treated the same as "b=2&a=1". There are also sometimes query string keys you want to ignore, like relurl. Without any testing done, the code looks like this: $correct_path = "/path/to/this/page.php"; $correct_qs = array("query string keys" => "query string values"); $actual_path = substr($_SERVER["REQUEST_URI"], 0, strcspn($_SERVER["REQUEST_URI"], "?")); // path up to the ? $actual_qs = $_GET; $ignore_qs = array_flip(array("relurl", "other keys to ignore")); // get a list of the actual values excluding the ignored values $diff_qs = array_diff_key($actual_qs, $ignore_qs); // get a list of just the ignored values $extra_qs = array_intersect_key($actual_qs, $ignore_qs); // if the path or query strings don't match if ($correct_path != $actual_path || $correct_qs != $diff_qs) { $target_qs = array_merge($correct_qs, $extra_qs); // the correct values plus the ignored values header("Location: " . $correct_path . ($target_qs ? "?" . http_build_query($target_qs) : "")); exit; }That kind of code should go into a function somewhere, naturally.
-
jQuery.noConflict If you call that then you cannot use the $ shorthand. At least not unless you take explicit measures to use it, like (function($) { // ... })(jQuery);
-
Oh. Well they're being stupid and not taking into account the query string. Those two pairs, at least, aren't duplicates. [edit] Well, technically the cart.php one is kinda duplicate because the relurl parameter does not affect the displayed page. You should noindex it. But that's a very minor concern.
-
PHP or static HTML does not make a difference. Either of those solutions will work and which you choose depends on the circumstance. Some degree of overlap is alright, but the problem is when you have more than one page which behave the same way or serve the same purpose. For example, with a forum like phpfreaks the friendly URL could be /topic/292324-help-with-fixing-my-seo-problems-on-a-php-site/but the backend URL (without rewriting) might be /viewtopic.php?id=292324Naturally both of those have to work on your site, but if you don't do anything beyond the rewriting then both of those URLs will generate the same page. That's duplicate content. With that example you should 301 redirect because you want people to use the friendly URL and not the backend URL. I can't come up with an example for canonical URLs but you would use those in cases where you want one thing to appear in two different places. The canonical URL indicates the "authoritative" or "primary" URL for the page so indexers will know that it's not so much duplicate content but rather content that is available in a second place (and it will focus on the first one). What kind of pages are being marked as duplicates? Of what other pages?
-
If they are the same site (same domain name) then it's just a matter of setting the session cookie... Getting into the xbmc-video-server code, that could be tricky. It uses the Yii framework to do logins, and like all frameworks you can't use just a part of it. The most straightforward way would be to do a POST request to the login page, with the right credentials, except you'd have to know their password. Then receive the cookie they try to set and pass it through to the user and redirect. You could also write something (eg, a new controller in the app) that would allow you to force a login for any user without having to know the password, but you'd have to be very careful about making sure it's not possible for anyone else to trigger that code.
-
As long as you're not calling the function on a different page load, yes. static function counter() { static $i = 1; return $i++; } echo counter(); // 1 echo counter(); // 2 echo counter(); // 3
-
It's all pretty easy and obvious, having users share login information: query the database, check credentials, blah blah blah... except when it comes to the cookies. The problem is that you can't set a cookie for a different domain. If you moved the xbmc site to, like, xbmc.userfrosting.com, then this whole thing gets much simpler. Regarding what Jacques said, you would have to be careful about how you implemented what I gave. At second glance it's not as brief as I thought so it's not as obvious that I was only giving the overview to the process. You basically have to make an API to your site exactly like how other sites might - it's just that you only have one website using that API. Along with it you need to deal with an authentication system (API keys and the like), input validation, and all that kind of stuff. The level of security varies, from simple to paranoid, but you have to have something for it.
-
header("Content-Disposition:attachment;filename=\"$row{['file_name']}\"");The variable there is a bit off. The {}s should be around the whole thing, like header("Content-Disposition:attachment;filename=\"{$row['file_name']}\"");
-
Unless they're using the same domain name, you'll have to set up a sort of information-sharing scheme where one website can tell the other about a user. Basically, 1. User is on website A 2. You/the user decides to visit website B and they need to be logged in 3. Website A "calls" website B (for example, with a POST request) and passes along information about the user 4. Website B stores that information somewhere then returns (a) whether the user was accepted, and if so (b) a special, unique, one-time URL 5. Website A redirects the user to that URL 6. Website B now uses that special URL to look up the information it stored earlier and log the user in
-
Your form has method=get. That means anything you specify for the query string in the action will be lost in favor of whatever you put in the form. Leave the action empty and use a hidden input for the page name. <form action="" method="GET"> <input type="hidden" name="page" value="EditPost">