Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. This may just be a typo when posting, but incase it isn't: You use $B in the parameter list, but $b in the function body.
  2. "It depends" is about as good as you'd get really. The function could execute very quickly or it could be a bit slow. Since it involves the file system, the biggest influence on how only it takes to run will be the current disk I/O load and whether or not the stats for that file are already available in memory or need to be read from disk. If everything is already in memory and no disk I/O has to be preformed to get the information, the function would likely run in 1ms or less. However if it has to hit the disk it'd take probably at minimum whatever the disk's seek/access time is. Probably around 8-10ms or so. That's assuming the request can be serviced immediately. If there is currently a lot of load on the disk (lots of things all trying to read or write data) then the request may be delayed. How long it's delayed will depend on the load.
  3. || is the operator to use for a logical-or condition. As in Cond1 || Cond2. So just create a second anchorVal.match test and stick it after the current one and put a || between them. You also want to surround the whole condition (both anchorVal tests) in parenthesis to make sure everything is evaluated in the proper order.
  4. It's just personal preference mostly, however using curly-braces is more common than the alternative (colon/endif) syntax in PHP files. I personally find the alternative syntax to be more legible within template files where your mixing PHP and HTML. Such as: <p>Some HTML or something</p> <?php if ($blah): ?> <div>Some conditional HTML</div> <?php endif; ?>
  5. See this page: How to remove hash from url?
  6. You can't use in_array at all. That function does not support any sort of wildcard matching. What you need to do is use a foreach loop on the array to test each element individually using something like preg_match. Then you can wrap that code into your own function for easy re-use. Such as: function fuzzy_in_array($regex, $array){ foreach ($array as $item){ if (preg_match($regex, $item)){ return true; } } return false; }
  7. A SELECT doesn't change the values in a row, only reads them. To modify the value you need to issue an UPDATE statement.
  8. SELECT `end`, DATE_ADD(`end`, INTERVAL 30 MINUTE) FROM `my_table` WHERE `ID` = 3 That will show you the original value and the modified value side-by-side so you can do an effective comparison.
  9. Verify that your data is what you think it is. Your example data works just fine for me, and I see no reason why it wouldn't: http://sqlfiddle.com/#!2/96453/1/0
  10. @Psycho: Aye, guess I didn't read close enough. @Pain: As a side note, there is one caution warning to be aware of with setInterval. If it's possible that the time needed to run your code would be longer than the delay, you should use setTimeout instead to prevent overlapping / queued up calls to the function. With a 10-sec delay that probably isn't an issue for you, though if you're doing any ajax work in the callback you might consider changing formats.
  11. Another thing you'll need to consider is how you want to handle holidays. I assume they would be excluded as well. You'll need to maintain a list of holdays and their dates in order to exclude them.
  12. with clearInterval.
  13. That is the directory for your user preferences where you can change the configuration settings of spamassassin. You need the location to the spamassassin executable file, which most likely is something like /usr/bin/spamassassin or /usr/local/bin/spamassassin. The following PHP script may be able to locate it for you. If not, ask your host again but make it clear you need the location for the executable, not the preferences. <?php system('which spamassassin'); ?> Stick that in a file, upload it to your site then run it.
  14. Check the return value of $stmt->prepare, it's probably failing. Add some code to report mysql's errors to see why it fails.
  15. For things like this what I do is store a base version which then would be copied over to the real version in each environment and customized for that environment. The real version gets put on the ignore list to prevent it getting added to the repo. Eg, for my site config files, I'd have a file in the repo that is named: config.inc.php.base which contains all the config directives w/ default or empty values. Then whenever setting up an environment that file is just copied to config.inc.php and customized with the proper values. The same concept could be applied to your .htaccess file, or any other files that need site-specific changes.
  16. Because at the point when your script executes, your form does not exist yet. You need to move the script after the form, or change it to run onload.
  17. Add a column to store either when they were added, or when they should be removed. Then you can just compare that date to the current date. For example: create table users ( userid int primary key auto_increment , username varchar(20) , expiresAfter Date ) Then when you add a new user, set the expiresAfter to the current time + 4 years occ insert into users (username, expiresAfter) values ('test', NOW()+INTERVAL 4 YEAR) If you really want you can then setup something to run a DELETE query occasionally but deleteing them is not really necessary. Just test that field whenever your listing out the users, eg: SELECT userid, username FROM users WHERE expiresAfter < NOW()
  18. Did you create/import a setcookie() function with javascript, or are you trying to call PHP's setcookie function? If the latter then, you can't do it like that, you need to use ajax or reload the page (ie, use a normal link to a .php file, not onclick). Either way, the value you're passing as the third parameter is almost surely wrong. If you're trying to use PHP's setcookie, you need to remove the quotes around the third parameter. If you have a JS function then it probably would be expecting a Date object, read the docs for the function. Lastly setting the cookie isn't going to cause the if to be re-evaluated and appear right away, you'd need to reload the page to see it change. An Example
  19. To test if a cookie is set or not you'd use this: if (document.cookie.indexOf('eucookie=') == -1){ //cookie is not set } else { //cookie is set } You can't conditionally include/exclude blocks of HTML with JS like you can with PHP though (by just wraping it in an if). You'd have to convert the HTML into a JS string and use document.write or do something onload.
  20. for ($i='a',$x=0; $x<100; $x++,$i++){ var_dump($i); }
  21. The umask function takes one argument, which is the new umask to use. By doing umask(0) you're passing in 0 as the new umask, which essentially disables it.
  22. Read through this thread and see if it helps clear things up: When To Use Try-Catch Exceptions If you still have questions or something is confusing post back.
  23. Same problem exists with your tags still: http://bit.ly/WrGb2C
  24. The one I linked to up above:
×
×
  • 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.