Jump to content

ManiacDan

Staff Alumni
  • Posts

    2,604
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by ManiacDan

  1. Depends on how many people will be rejected and how you want to handle that.  If a very small percentage will be in "rejected" or "pending" state, then the enum is a good idea.  If a large number, a separate table may be faster.

  2. If you don't know anything about ajax, we can't teach you from the ground up.

     

    The basic idea is that the request object allows javascript to call a URL and retrieve some formatted data, then parse that data and perform relevant actions.

     

    You'll need to write a page that accepts a value (maybe a cookie) and returns the relevant data you're wanting as a bare string.

     

    Then look up how to do an AJAX GET request using jquery (or by hand).

     

    Have the ajax request hit the page you wrote, then move on from there.

  3. What I'm saying is:  What purpose does this entire server serve if it does nothing but forward all requests to a second server?  if I try to hack your server, this "proxy" will just forward my hack attempts along.

     

    You've never seen this before because the thing you're trying to do doesn't make any sense.

     

    I've worked with systems where business and display logic were on separate servers.  They used an internal API.  But your system is already designed, and you have just now thought about this problem.  It's too late to separate your logic into different servers.

  4. You already agreed you were starting from the root.  Why did you say that if you aren't sure what it means?  

     

    The "root" of something is the base of it.  C:\ is the root of a windows file system.  / is the root of a *nix file system.  phpfreaks.com/ is the root of phpfreaks.  You should start from your "web root" for file includes so you always know you're getting the right file regardless of where you are in the filesystem. 

  5.  But in a case that having an instance is undesirable/impossible, I don't see an alternative.
    So you're saying that this is impossible/undesireable:

    $a = new a();
    $a->foo();
    unset($a);

    So instead you make a function bar() on A:

    public static function bar() {
      $a = new a();
      $a->foo();
    }

    Why?  All you're doing is causing a class to nest inside a non-instantiated version of itself.  It's confusing and entirely unnecessary.  All you're doing is adding overhead and seriously confusing code.

  6. Only static functions can be called statically.  To fix that error, add "static" to your method declaration for the other method.

     

    And before you ask: you no cannot call a dynamic method from a static one.

     

    Bravo for having error-reporting turned on, well done.

  7. If you really love split, I have good news for you:  Actually reading the manual page would give you 4 alternatives to split that actually work properly and aren't deprecated.

     

    Parse_url pulls out the query string, then parse_str will parse the query string for you.  That's the only correct way to do this.  You can continue splitting the string if you want, but I've already demonstrated a valid URL which will break your method and not mine.

  8. If you don't get an error when you run this code, you have errors turned off, and that's bad.

     

    As a language grows (any language), new features are added.  Some of those new features are better, more efficient, or more secure versions of old features.  The old features are then deprecated (marked as "old").  After a few more version, deprecated functions are removed entirely.  Functions like ereg, split, and register_globals, as well as variables like $HTTP_POST_VARS are deprecated.  Soon, they'll be gone.  

     

    Right now, your code throws an error.  Maybe when PHP6 comes out, it will stop working.

     

    Just because something is possible doesn't mean it's the best way to do something.  You're trying to parse a URL.  The function I pointed you to is called "parse url."  Using a deprecated regular expression engine (which is really slow) to split it into uneven chunks in the hopes that it comes out with the right answer is just...not going to work out well for you.  For instance, this is a valid youtube URL:

    http://www.youtube.com/watch?v=ruJ1uFf9hy4#t=2m14s

     

    Your code would break on that.  Using parse_url would not.

  9. I have no script to share, I linked you to the manual page of a function which does exactly what you're asking for.  Read the page, learn something new, and apply that knowledge to write a script.

     

    Speaking of the manual, did you happen to read the manual page for the split function you're using?  See the big red box that says using the function is highly discouraged?  

×
×
  • 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.