-
Posts
15,266 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
Can't send any email from youhosting server
requinix replied to Khalequzzaman's topic in Other Web Server Software
What's the code you're using? What happens when you run it? Exactly what does "can't send any email" mean? Do you get any errors? Is your code even checking for errors? -
Use pathinfo to get the extension. Remember that the extension may not be entirely lowercase. You can omit the directory portion of the filename by using basename. Also check that the filename is a file, which will make sure the file exists and block any attempt to delete directories like . or .. (which would fail anyways).
-
Want to return a variable from PHP page to my main page
requinix replied to dezu's topic in PHP Coding Help
Do the authentication before accepting the file upload, then confirm they're still authenticated when actually accepting the upload. Authentication at the time of an upload isn't a great idea because (a) the user has to wait for the upload before they'll get the authentication dialog, and thus (b) if they fail authentication, such as by mistyping their password, then they have to go through the upload process another time. For the new tab, the simplest thing would be to point the form to a new page (target=_blank) and have the output of the upload script be the "source of the file" or whatever. -
Change item?id=1234 to /item/1234 with htaccess
requinix replied to slj90's topic in Apache HTTP Server
1. What does the error log say about the 500 error? 2. If you use the [R] flag I mentioned, where does your browser get redirected to? If there is a loop then you might not see it and have to look at the server's response headers to find out. -
The name is "list[]". Am I missing something?
-
You shouldn't assign to an on* event handler directly as it only allows you to use one handler per element per event (using that method). Use event registration instead. There are browser differences so it's easier to do with a Javascript framework, but if you want to do it manually then you use element.addEventListener or element.attachEvent. // a quick and simple helper function function registerEventListener(element, event, handler) { // IE9+ and other browsers if (element.addEventListener) { element.addEventListener(event, handler); } // IE<9 else if (element.attachEvent) { element.attachEvent("on" + event, function() { // in here, this != element handler.call(element, window.event); }); } } registerEventListener(document, "keydown", function(e) { // e is already normalized to the event object var key = e.keyCode || e.charCode; // ... });Note that key has the var keyword too. Without it you create/assign properties on the global (ie, window) object, and that creates clutter, and clutter is bad. For the second question, for printable characters, keydown will repeat as long as the key is held down. Which you've discovered. If you want to do something once then you want to do it the first time the keydown event happens, and then reset when the keyup happens. (function() { // separate scope for this variable var once = false; registerEventListener(document, "keydown", function(e) { if (once) return; once = true; // ... }); registerEventListener(document, "keyup", function() { // reset once = false; }); })();That may be a little finicky if you try multiple keys at once.
-
Finding words with ' in them and not mistaken them for code
requinix replied to 0o0o0's topic in PHP Coding Help
Backslash. Or use different quotes for the string. 'Ryan O\'neill' "Ryan O'neill" -
Is it as simple (in your case) as saying "remove all the whitespace between a > and
-
Change image on website based on time in day
requinix replied to krishh33's topic in PHP Coding Help
How many images will you need? Like a dozen or so, or many more? Will you ever want to change them (either the images or the times) and if so how often? -
Caching does not happen by default - only if something on your server told the browser to cache the content. Versioning isn't really that great of a solution, given that there are others which can cause caching to happen the way you want, and more suited for when you don't have control over the server sending the content (like a CDN). What are the response headers for a page on your site that gets cached? Your browser might have something built-in to see them, or you may need an extension. Caching headers include Last-Modified, ETag, Expires, Cache-Control, and Pragma.
-
There's a newline at the end of the file. How you deal with that is up to you: remove the newline, trim() it off, use a different function than fread() which stops at newlines, use file_get_contents() and avoid the whole file opening thing though you'll still have the newline...
-
0xc000007b is generally a problem of mixing 32- and 64-bit applications with DLLs. Are you sure you downloaded the right files and extensions?
-
How to interrupt function execution after X seconds?
requinix replied to helices's topic in PHP Coding Help
Well then, if that's your code: 1. You're missing an opening <?php tag 2. $prog is undefined 3. $fd is undefined 4. $pipes is undefined 5. $ldir is undefined 6. You don't do anything with $proc I'm not asking for a single line of code where you think the problem is. I'm asking for ALL of your code. -
How to interrupt function execution after X seconds?
requinix replied to helices's topic in PHP Coding Help
What's your code? That should not block, or at least not for long. What you do or don't do afterwards may cause problems. It does not require ticks, but depending on what you do in your code the alarm signal may not be handled without using ticks. Again, depends on your code. -
You're using PHP to run a batch file to run an application? Post code.
-
How to interrupt function execution after X seconds?
requinix replied to helices's topic in PHP Coding Help
Ticks aren't deprecated... Either ticks won't help you because you're waiting on an external process to complete, or ticks can help because you have code that's actively running but then you don't need ticks in the first place. Apparently it's the latter. Besides, ticks only work in certain PHP setups. What's your code? -
Rather than use the hammer you know to hammer in a screw, learn to use a screwdriver. Install ntp/ntpd/whatever the name of the package is called on your (presumably Linux) distro. And make sure the system is using the right timezone. That's it.
-
unable to override php's default exception Messages
requinix replied to ajoo's topic in PHP Coding Help
Make sure you're still logging those errors, though! You may not want the error message to appear on your site but you certainly should be aware of any problems. -
Apache needs the slash if you want it to serve whatever DirectoryIndex file (eg, index.php) automatically. If you want to turn the slash off then you have to (a) add it back yourself or (b) do the work of serving the index.php yourself. # do not automatically append slashes to directories DirectorySlash off # do automatically use index.php RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*[^/]$ $0/index.php [L]
-
The most appropriative way of using data formats
requinix replied to web_craftsman's topic in PHP Coding Help
Guess not. -
having 6 random numbers output different numbers
requinix replied to cloudll's topic in PHP Coding Help
You can avoid a loop with $my_numbers = array_rand(array_flip(range(1, 100)), 6);or the cleaner $rand_nums = range(1, 100); shuffle($rand_nums); $my_numbers = array_slice($rand_nums, 0, 6);There won't be much of a difference if you're only getting 6 numbers out of 100, but if you tried more like 6/7 or 90/100 then you'd notice a big one. -
Then they didn't get the initial setup correct. What your extension_dir setting and what extensions (as in the actual extension= or zend_extension= lines) are you trying to load?
-
The first error is something you should contact your hosting company about. Unless you went out of your way to configure a PHP extension? The second depends on the code so posting that file (config.php) would help.
-
Done.