Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. You can use the "DISTINCT" keyword which will only return rows in the database that are unique - that means every column selected has to have the same values for it to be considered a duplicate (i.e. if the ID is different they won't be considered distinct). You should really fix the problem at the source though, and remove the duplication through a technique known as database normalisation.
  2. You're receiving the error because PHP has already sent the headers to the browser, at the point where you're trying to send a 'location' header. PHP does this as soon as it encounters any output; be it HTML, text or even white-space. Looks like you have some white-space before the opening <?php tag in check_login.php - remove that and the error should go away.
  3. Hmm.. Is your login detection just checking if a cookie is set? What's to stop me setting a "ID_my_site" cookie to your username?
  4. Great stuff! It's just basic math really, once you've get the millisecond difference between the two dates. Also to answer your second question, you only need to declare the variable once with var, after that you can just redefine it like in your second example. One thing to note about JS compared with PHP is that variables declared in the global scope are automatically available within functions, unless you declare a local copy with var.
  5. The 'UNIX timestamp' is basically the number of seconds since 01/01/1970?
  6. By using the object in a string context (document.write()) you're invoking the toString() method automatically. You need to call getTime() to get the milliseconds since the UNIX epoch: document.write(test.getTime()); Also if you want the time in seconds, you need to divide it by 1000: document.write(test.getTime() / 1000); Edit: I originally said multiply, it's divide, of course
  7. Take a look at the JavaScript Date object. You can pass in parts of the date string into the constructor, similar to how you would with mktime().
  8. I would ensure it's not against the ToS first, but you could use cURL to send the HTTP request in the background. http://php.net/manual/en/book.curl.php
  9. Ah sorry, there is an indexOf array method. I always thought there wasn't one :S .. Unfortunately though there's no support for it in IE prior to version 9. Using it does keep your code a lot cleaner though, so you could use the prototype object to define it for any browsers that don't already have it: if (Array.prototype.indexOf == null) { Array.prototype.indexOf = function(search, fromIndex) { var length = this.length; var index = (typeof(fromIndex) !== 'undefined') ? fromIndex : 0; for (index; index < length; index++) { if (this[index] == search) { return index; } } } }
  10. Open up Chrome's debugging tools and switch to the Network tab. Reload the page and watch the timelime - that should highlight any resources that could be causing the page to hang. If not, are you outputting a document.write() JavaScript function anywhere?
  11. That's because indexOf() is a string function, not an array function. You can't actually have an associative array object in JavaScript either, they're all numerically indexed -- the equivalent would require you to use just a plain object. Given you're not trying to assign any keys in the array definition though, I don't see how the choice variable comes into it?
  12. It's still fairly early days, but Adobe Shadow's been a blessing for testing on mobile devices at work over the last few days. You essentially just sync a bunch of devices (with the iOS or Android app installed) to your computer over the network, and then navigate around (using Chrome with the shadow plugin) on your computer and each device will navigate to the same page. Makes testing on a whole bunch of different devices much quicker and a lot less tedious! The best bit though is that you can use a slightly simplified version of Chrome's developer tools to debug each device individually - it's mint! http://labs.adobe.com/technologies/shadow/
  13. I'd say it seems excessive to check a character on a key stroke event against (up-to) every character for every right-to-left language. (Admittedly though I have no clue just how many characters that is.) Having said that it's not impossible of course, but I would utilise the server to do the work (through an AJAX request) so that as entering text the textarea doesn't become slow or unresponsive, which may be more likely on mobile browsers. I would offer the option of disabling this too, and making it manually selectable.
  14. Then you need to define what you mean by "change language"? Is this a drop-down type menu that user selects their language from or something?
  15. You can detect the user's language using the "Accept-Language" HTTP request header. I don't believe you're able to reliably get this through JavaScript though, so you'd need to use PHP (through $_SERVER['HTTP_ACCEPT_LANGUAGE']). Using that though, as you generate the page you can set the HTML dir attribute or the CSS direction property appropriately. Edit Don't try to detect the user's language as they type. Just base it off the language their browser is configured with (using the header I mentioned before).
  16. You can't have a control structure within an echo like that. You would need to loop through prior to the echo and build up a string, that you then concatenate into the echo.
  17. Adam

    Google Wage

    How dare Google make a mistake
  18. Adam

    Wow.

    He has a YouTube video!? Well my god it must be true!! Nah sorry i'm with scootstah here. It just sounds like a crazy David Icke conspiracy or something, not a rational theory or whatever it's meant to be.
  19. Look at the source.
  20. This computer's about a week old - definitely isn't the cache
  21. I would strongly encourage you to stick to just one framework. Generally JS frameworks internally contain the same stuff, so you're just doubling the resources needed for no good reason. If you still want to go ahead for whatever reason, then you'll need to use jQuery.noConflict() (or the mootools equivalent) to remove the global $ alias variable, as both frameworks by default use this as a shorthand. You'll then need to invoke jQuery using jQuery, instead of $. For example: $('...'); Would become: jQuery('...'); However using $ does speed up development a bit and keep your code cleaner, so you could use an 'immediate function' with a local-only $ alias instead: (function($) { // Normal $ jQuery calls here })(jQuery); jQuery also supports this in the .ready() event: jQuery(document).ready(function($) { // Normal $ jQuery calls here });
  22. Can you define 'active' please?
  23. I'm getting a 'CloudFlare website offline' error?
  24. I agree, you're not posting a coherent explanation here. ... Though it is possible that name is defined. Variables defined in the global scope in JavaScript are available within global functions. To declare the variable only within the scope of the function, you need to redeclare it with var. So that also means, for future reference, that if you change the value of a global variable within a function without redeclaring it, you will change the global value too.
  25. Welcome! How do you know it's nearly 2 million, out of interest?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.