-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
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.
-
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.
-
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?
-
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.
-
The 'UNIX timestamp' is basically the number of seconds since 01/01/1970?
-
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
-
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().
-
How do you call a web page and get a result without the page to be seen??
Adam replied to gnetuk's topic in PHP Coding Help
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 -
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; } } } }
-
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?
-
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?
-
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/
-
change writing direction in a textarea box when user change language
Adam replied to lofaifa's topic in Javascript Help
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. -
change writing direction in a textarea box when user change language
Adam replied to lofaifa's topic in Javascript Help
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? -
change writing direction in a textarea box when user change language
Adam replied to lofaifa's topic in Javascript Help
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). -
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.
-
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.
-
This computer's about a week old - definitely isn't the cache
-
I think i have jquery conflict problem help please
Adam replied to Lisa23's topic in Javascript Help
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 }); -
Can you define 'active' please?
-
I'm getting a 'CloudFlare website offline' error?
-
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.
-
Welcome! How do you know it's nearly 2 million, out of interest?