Jump to content

requinix

Administrators
  • Posts

    15,227
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. No. You could combine two things into one "value" but that's generally a bad idea. I see two possibilities: 1. Friendships go both directions: if A is a friend of B then B is automatically a friend of A. In which case there should only be one record which one side being the current user and the other side being the other user (be that requestor/requestee or vice versa). And the query looks like WHERE (requestor = current user AND requestee = other user) OR (requestor = other user AND requestee = current user) 2. Friendships are unidirectional: if A is a friend of B that does not mean B is a friend of A. In which case the requestor is always the current user and the requestee is always the other person. Either way you only need to keep the other user's ID in the form.
  2. It's your query. The problem is in your query. That's why it says "in your SQL syntax". What's your query? Or rather, what's the code to generate the query?
  3. But the request, not the response. (Which is what OP meant since requests don't have status codes.)
  4. Doesn't work well how? What if you remove the leading slash?
  5. Dunno, but you'll probably end up using array_combine.
  6. And on the other hand there's terms like "global variable" and "global scope"...
  7. You mean you think OP actually meant literally global?
  8. What's your code?
  9. Then you need something somewhere that tracks all the ID numbers. Like a database table with an auto_increment field, then all the other tables's primary keys are actually FKs to that table (and don't have auto_increment themselves). query("INSERT INTO global_id_table (fields that help identify what this ID is for) VALUES (information or description or something)"); $id = get insert ID(); query("INSERT INTO real table (ID, fields) VALUES ($id, values)");
  10. Can I do what? If you're using 5.4 then you have http_response_code, otherwise you'll have to write something yourself. Assuming you'd be writing PHP code for this, you wouldn't be able to use header() directly as your new code wouldn't know of the new response code.
  11. So change it to something you prefer. Like rather than call show() you can set a view name using a default of "(action)View.php". The Router then calls a method on BaseController to show the view, and that method basically does $this->registry->template->show($this->viewName); I would structure it like // router controller = new controller; controller->execute(action); // BaseController::execute this->viewName = action + "View.php"; this->action(); this->registry->template->show(this->viewName); // controller::action this->viewName = "customView.php";
  12. It's always 200 unless you change it yourself... You're talking about the status code of the page that PHP is currently rendering, right? Of the script that's executing?
  13. If it's your own framework then you do it however you want... You have some code that calls the controller/action, right? Shortly after that it can render the view.
  14. Give it a shot. Here's something you can use in it: function timediff($start, $end) { sscanf($start, "%d:%d:%d,%d", $shour, $sminute, $ssecond, $sfraction); sscanf($end, "%d:%d:%d,%d", $ehour, $eminute, $esecond, $efraction);
  15. Not sure what you mean, but $number comes from the matched groups in the search expression - the ones you put ()s around. If you had /([0-9])\s+([0-9])([0-9])/ (which is inefficient but suitable for this example) then $1=the digit before the space, $2=the digit immediately after, and $3=the digit immediately after that. \1, \2, and \3 also work. If you wanted groups of numbers then you'd have to change the expression a little: it only matches individual digits right now. /(\d+)\s+(\d+)\s+(\d+)/ with \d being shorthand for [0-9] and + meaning "at least one of", then $1-3 are the first through third numbers. Then you'd replace it with $1,$2,$3 (or \1,\2,\3)
  16. Are you sure it's really a space and not a tab or newline character?
  17. That would be fine but you aren't adding back in the two digits that the regex matched. $replacement = '$1,$2'; Or you could use lookarounds but I personally avoid them when possible.
  18. I should have been more specific: I see a FILEINFO_MIME but not a FILEINFO_MIME_TYPE.
  19. ...Where?
  20. preg_match_all() basically is the /g flag. Unfortunately I'm too tired to be able to explain it right so that's the best sentence I've come up with yet. Meanwhile /g and /m have nothing to do with your problem. Global only matters when you're trying to get the matches themselves (you're just testing that one exists) and multiline mode only affects end- and beginning-of-line anchors (you don't use any). What is the exact value of $string?
  21. Pass ->buffer() the FILEINFO_MIME_TYPE option.
  22. Yes. split() uses regular expressions and a pipe | is a special character ("alternation") in one. Thus you have to escape it with a backslash \ to get a literal "pipe character". explode() does not use regular expressions, which is great because you don't actually need them. Plain strings don't have concepts like "alternation" or "escaping"* so no backslash. * I'm not talking about PHP's deal with singly- and doubly-quoted strings. I mean the characters within them, not their representation in code.
  23. I'm not looking for just quote=b. :/ I'm looking for [tt]
  24. [a-zA-Z0-9] By itself that means only one. It would work with quote=b. Add a "quantifier" to it - which one depends on what you want to allow.
  25. What do you have now? I ask mostly because I don't know what inputs you're starting with.
×
×
  • 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.