-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
Sorting multidimensional array on date - again
kicken replied to Drongo_III's topic in PHP Coding Help
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. -
How much processing does PHP take to perform 4 x is_file() actions?
kicken replied to johnsmith153's topic in PHP Coding Help
"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. -
|| 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.
-
Is either if statement "neater" or more legible than the other?
kicken replied to MySQL_Narb's topic in PHP Coding Help
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; ?> -
See this page: How to remove hash from url?
-
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; }
-
A SELECT doesn't change the values in a row, only reads them. To modify the value you need to issue an UPDATE statement.
-
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.
-
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
-
@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.
-
Date / Time difference using only working hours
kicken replied to Clarkey's topic in PHP Coding Help
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. -
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.
-
Check the return value of $stmt->prepare, it's probably failing. Add some code to report mysql's errors to see why it fails.
-
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.
-
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.
-
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()
-
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
-
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.
-
for ($i='a',$x=0; $x<100; $x++,$i++){ var_dump($i); }
-
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.
-
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.
-
Same problem exists with your tags still: http://bit.ly/WrGb2C
-
The one I linked to up above: