Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. I'd get rid of the individual public variables and use __get/set instead, with an array containing the actual values. Then it's easy: $_settings is the array and you merge the $options into it. /** * @property string $category * @property string $title * @property string $option2 * @property string $show * @property string $output */ class VarDataClass { private $settings = array( 'category' => 'DEFAULT CATEGORY', 'title' => 'DEFAULT TITLE', 'option2' => 'DEFAULT VALUE', 'show' => 'SOMETHING', 'output' => 'box' ); public function __construct(array $options = array()) { // array_intersect_key so only recognized $options get merged in $this->settings = array_merge($this->settings, array_intersect_key($options, $this->settings)); } public function __get($name) { return (isset($this->settings[$name]) ? $this->settings[$name] : null); } public function __set($name, $value) { if (isset($this->settings[$name])) { $this->settings[$name] = $value; } } }
  2. Yup, that was a typo.
  3. What's the code you have now? Because apparently it's sending vSubmit and vName and other vThings and the new code doesn't have those. { zProduct: zProduct, zBay: zBay, zMeasures: zMeasures, zDoor: zDoor, zPlinth: zPlinth, zMount: zMount, zBattery: zBattery}Where are all those values being defined?
  4. Can you post the whole thing instead of just a couple lines?
  5. is_dir Remember that $file is not the complete path so if you do is_dir($file) it will not work.
  6. It is matching 10. To get that value you do $matches[1] with no more array offsets after it. Because if you do $matches[1][0] then you'll get the first character of it.
  7. This is not a job for regular expressions. Read the file line by line and build up a list of serial numbers for each item. When you're done accumulating for each one (ie, when you read a new item or hit the end of the file), write the complete item back out to a new file. Or not a new file and read everything before you re-open and write.
  8. Huh. It did exactly what I said it would. The .php is being added because of the first rewriting rules RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.phpbecause "/new_folder" isn't a file. It should be ignoring directories, which you can do with RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/$ $1.php
  9. Yes. Yes. That particular problem rarely ever causes any issues so focus on other problems first.
  10. Right. I put comments into the one you already had. I'm saying I don't see any opportunity for a loop. "/new_folder" will match the first set and redirect to "/new_folder.php". That then won't match any of the four sets and so... no loop. Could you just try it and see what happens?
  11. I don't see how since none of the other RewriteRules will match it. # won't match because it doesn't end in a slash RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php # doesn't contain slash, doesn't end in a slash RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php # has a file extension RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] # irrelevant to this discussion RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  12. Copy and paste? Make sure the variables are using the right names.
  13. Put a [L,R] in each RewriteRule to see where you're being rewritten to; I think you'll end up at /new_folder.php.
  14. case "jpg" OR "jpeg":Can't do that. It's like saying if ($ext == ("jpg" OR "jpeg")) {which means if ($ext == true) {which will always be the case for strings like "jpg" or "png". Use multiple cases instead. case "jpg": case "jpeg": // ...
  15. That message has nothing to do with databases. The URL in the message 404s so it's probably wrong. Check your WAMP and DW settings to make sure they're both using the same URLs.
  16. Put all that code in a file, name the file "code.js", put it inside the /js/ folder, and then replace everything you have now with the that you want to have.
  17. Always use an absolute path. That could be with the "http://", or you could do it more easily with just "/images/abc.jpg". Try adding a DirectoryIndex index.php
  18. If you want to do a prepared statement using an IN then you need placeholder for every value. You know what's easier than that? Make sure all the numbers are integers, like with an int cast or intval(), then implode() it and put it directly into the query. As long as you're definitely, definitely making things integers here then you'll be alright.
  19. If you used any PHP 5.5 features then you'd probably be aware of it. More likely is a difference in the configuration between your environment and his. php.ini settings, extensions enabled, database credentials, that kind of thing. Ideally you would be testing your code in an environment that is as close to the real thing as possible - working in XAMPP and deploying to IIS (for example) is just asking for problems. Do a phpinfo() on both setups and see what the differences are.
  20. What you're doing wrong is making things static. Static values are the same for every single instance of the class. So don't do that.
  21. That's not it. The problem is that the inner function is executing after the rest of the outer function has completed. It's asynchronous. The functions will need to be restructured, probably such that the inner function submits the form (which the outer function used to do, I assume) and the outer function only validates. What's the rest of the code?
  22. What about .class1 .class2 { /* used to be #000 */ color: #0f0f0f; }and .class1, .class2 { border: 1px solid #999; }What do you want to get from that?
  23. How about a lookbehind at the beginning that ensures there wasn't a digit before? /(?!
  24. .htaccess doesn't know about your PHP code. It would be awkward to do it there. So do the redirection in code. if ($country == "INDIA") { header("Location: http://www.new-domain.com" . $_SERVER["REQUEST_URI"], true, 301); exit; }
×
×
  • 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.