Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Sure, your way would work just fine.
  2. Now you do! The only necessary change, to do what you described, would be: From this // Execute query. mysqli_stmt_execute($stmt); // Verify Update. if (mysqli_stmt_affected_rows($stmt)!==1){ To this // Execute query. $success = mysqli_stmt_execute($stmt); // Verify Update. if ($success === FALSE) { Don't beat yourself up over not realising that zero affected rows isn't an error. Learning material, particularly on the internets, often stresses the supposed importance of checking for the number of affected rows for INSERT/UPDATE/DELETE queries, as an indicator of success/failure. So much so, that it is easy to miss the fact that sometimes when there really is nothing to update, depending on what the script is trying to do, it's okay to not have any rows affected.
  3. Yep I follow you. The trouble looks to be that you consider zero updated rows as an error when that's not the case. If the logged_in is already 1, and you update it to 1, then MySQL will report zero rows updated --- but that's fine. You don't want to give an error message when no rows are updated. It looks to me like you should really be checking on the return value of mysqli_stmt_execute(), to see if something went wrong with the query; not counting how many rows changed.
  4. The logic in the code in the OP makes no sense at all. It reads... If the user is logged in, update the database to show that they are logged in. Whaaa? If they're already logged in (as shown by $_SESSION['loggedIn'] being true), and you update the database then of course you'll get zero rows updated because the database will be trying to update the logged_in column from 1 to 1 again.
  5. As a Lancashire chap, I can only disagree! (Though, secretly, you guys make a great brew too.)
  6. Fixed that for you. P.S. England does indeed produce some very fine ales, and lots of awful ones.
  7. {:70{}} Repeating the OP for clarity: "I need to adjust the regex to completely ignore whatever there is between curly braces".
  8. That still doesn't do what the OP asked for.
  9. AyKay47, your solution is not "based on the specifications in your post". Give it a go with {:70:} The OP said "numbers between { and } are ignored, even if they are surrounded by alfanumerical (or other) characters."
  10. It doesn't look so much like "your PHP" is way behind, but rather you have yet to be exposed to technologies commonly used in the daily routine of a professional PHP developer. Your best bet is to continue your individual research into those topics that you feel you're lacking understanding, as you know best what the technical interview was really asking (the short titles are very vague). If you're looking for discussion here, could you elaborate on the subject a little? E.g. You mention "compression" but that covers a multitude of possible things that they could have been asking about, what was their question(s)?
  11. Cookies themselves cannot harm a computer, they are dumb "text" files stored on the computer.
  12. I'm confused, are you looking for help or someone to do the work for you? (It's fine either way, but dictates the responses you'll get here.)
  13. Hi, welcome to PHPFreaks. Since you're a recruiter I have to ask that you do not contact anyone on the site unless they have asked you to contact them. Personally, I get enough annoying phone calls and emails from recruiters, I don't want to get hassled on forums too! If you're here to learn about PHP, then great, go wild.
  14. Bingo. If your current host won't even let you use a harmless function like json_decode(), then it is time to find another host. Where you get the impression that "most" hosts do not have, or do not allow, the JSON functions is beyond me. No host in their right mind would be without it.
  15. I call them "URLs". If you want to call them something different, or try and use a term that differentiates them from URLs with paths or other parts, then go ahead. You'll (probably) be understood. Do note that the word "base" is often associated with URLs in the manner you're doing here, though not necessarily restricted to those with no path. http://example.org/subsite may be termed, and understood as, a "base URL" if, for example, it hosted a sub-site within the main example.org website. Similarly, the word "root" might be used in place of "base" to have the same meaning. Calling them "base URLs" only makes sense if they are indeed the base of something (and URLs), which is the case.
  16. That's better than seeing an ad.
  17. The internal workings generally aren't documented, and what exactly this email validation accepts as valid would take a lot of describing (though it would be nice to have this). This email validation simply uses a regular expression. The exact regular expression used has changed over time since FILTER_VALIDATE_EMAIL was introduced, but you can see it in the PHP source code. Here it is for the upcoming PHP 5.4, http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/ext/filter/logical_filters.c?view=markup#l499
  18. The PHP manual is full of useful information, including suggested alternatives for deprecated features. See http://php.net/split In your case, explode() makes most sense.
  19. Worst. Comeback. Ever.
  20. Of course you can. /^(?=[a-zA-Z0-9]{8,20}$)(?=.*?\d)(?=.*?[a-zA-Z])/ This approach uses "look aheads" (?=...) anchored at the start of the string which might look a bit odd at first. The pattern basically says, at the start of the subject string does it a) contain only alphanumeric characters between 8 and 20 in length, b) contain something (or nothing) then a digit, and c) contain something (or nothing) followed by a letter. Reading: http://www.regular-expressions.info/anchors.html http://www.regular-expressions.info/lookaround.html
  21. What format is the date? strtotime() will accept m/d/Y but not d/m/Y.
  22. I think that having any Math help forum here is stupid. There, I said it.
  23. 1. What does it means ? Commercial experience is time spent working and being paid for it, e.g. going to work and writing code. If you have ever worked as a PHP developer and gotten a pay cheque then it is commercial experience. Making an "e-commerce store" for your mom's friend's auntie's neighbour's cat's kitten does not count. Making an amazing blog and selling it on Ebay does not count. Writing the most amazing site in the world, in the evenings before bed, does not count. 2. How can I gain commerical experience? Get a job.
  24. strtotime() does not understand that particular format of date (day<space>month<space>year). The list of accepted date formats can be found under Date Formats.
×
×
  • 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.