Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. The 1 selects the mode the function runs in. There's a list on that page near the top. The $i variable is the key.. the array returned looks like this: array( 'c' => 5, '.' => 1, '-' => 3, ); That foreach loop sets $i to be the "key" or "index", which is the character, and $val to be the "value", which is the number of times character $i appears in the string. Try the example script with a few input strings to get an idea of what's going on.
  2. A for loop isn't the right structure here. Sessions would be appropriate. At the VERY TOP of your script, before ANY output at all, add session_start(); Then, each time a guess is made, do $_SESSION['guesses'] += 1; Then, each time the script is run, also do if ($_SESSION['guesses'] == 7) { echo "You're out of guesses!<br>"; }
  3. How doesn't it work? Blank screen? Are the queries being executed? I would start by adding an echo inside the if statement: echo "Updating id {$row[8]} because $arrives >= $today2 <br>";
  4. You can change the query like this: $strsql = "Select name,empid,vendorid,idemp from people where usercode = 'EMP' and local = '$local' and name ilike '$prefix%' order by name"; "ilike" does case-insensitive matching, "like" does case sensitive matching. $prefix is the variable for your new form field.
  5. There's a function specifically for that: http://sg.php.net/manual/en/function.count-chars.php
  6. There's nothing wrong there.. if it works without the or, it will work with the or. I suggest you double check that it works without the or. Try printing out the values of each variable just before you do the comparison. Also, you should use either 'fquart' (for a constant) or $fquart (for a variable).
  7. That sounds quite difficult to achieve. base64 will work against someone who is not a programmer, but I assume admins would have some basic programming knowledge. Something which would be secure is to use the user's password to generate an encryption key. For example, the user enters 'trustno1' as their password. The password is hashed with md5() and compared against the hash stored in the database. Then another hash is generated, which could be done by appending a fixed string to the password. This hash is used to encrypt and decrypt that user's journal entries. The big problem there is that a change of password will require re-encryption of all entries.. And forgetting a password will mean loss of all entries. Not such a good idea maybe
  8. If you require area code it's simple.. and here you need to escape the brackets. [code=php:0]'\(?[0-9]{3}\)?[0-9]{3}[.-]?[0-9]{4}'[/code] You might want to strip spaces first in case someone adds them in.  I made some things optional with "?", and allowed either "." or "-".  This regexp might be too strict, since people might use other characters as seperators.
  9. Unfortunately there is not, using the default myisam tables. Unless you switch to another table format which supports transactions, the best you can do is to clean up afterwards when something goes wrong. http://dev.mysql.com/books/mysqlpress/mysql-tutorial/ch10.html
  10. Details are here: http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html Look at the bottom of the main section, above the user comments.
  11. I'm very surprised it doesn't use huge amounts of memory in windows, since you are instructing php to read the entire file in. There's no way that can be optimized away. The script says 1. Read in the entire file 2. Apply rtrim to every line 3. Iterate over the array Even the smartest interpreter can't avoid allocating that memory.. it's very strange indeed.
  12. That's not the problem.. () is perfectly fine within [].  The problem is that {10-15} should be {10,15}.  I agree that the error message is NOT helpful
  13. You can't use include() for that. You should use readfile() instead. To preserve the $_GET variables, you will need to explicitly add them to the readfile() call, like this: readfile('http://www.domain.com/main/page2.php?test=test'); As for doing that in practice, you can hardcode it if you only expect a fixed set of $_GET variables. Otherwise you can use a foreach loop to add each $_GET variable.
  14. I don't really understand your question. If you incorporated what, would it be insecure?
  15. I think you just need && instead of ||. || means "or", && means "and"
  16. Also see http://bugs.php.net/bug.php?id=25483&edit=2
  17. According to IBM: "-469 This descriptor does not exist. The name of the system descriptor area that is specified does not exist in the list of system descriptor areas, so it has not been allocated. You must execute the ALLOCATE DESCRIPTOR statement to allocate this descriptor name before you use it." http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.em.doc/errors_ids100.html Is that helpful?
  18. If you use an id as well, it's the same problem really.. someone who types someone else's username, id and password will be able to login. You might be able to add security by restricting which ip addresses can login as which users. That's not practical for large sites though, as plenty of users either won't know their ip address or will need to login from different locations. Or both Really, a password is enough security unless you're protecting something very sensitive. Banks here use devices which generate one-time time-sensitive codes which you have to enter along with your id and password to access online banking. That solution might be out of your budget
  19. That's Matt Bellamy from Muse The original avatar was animated.. it has him doing some weird thing with his hair. I heard he was voted "sexiest man" by NME..
  20. Not mysql_connect(), mysql_query(). It should be: $result_war = mysql_query("SELECT * FROM fusion_wars WHERE `a_id`='$user_id' AND `d_id`='$target_id'") or die("Query failed: " . mysql_error()); Or in your code you appear to use dbquery() instead of mysql_query(). Edit: Fixed ' => `
  21. Yes, if you type in someone else's username and password, you will be able to login. But the odds of having the same password are very small, unless both people happen to like the same tv show (trustno1) or the same band (blink182)
  22. The DOM interface changed between php 4 and 5. Check these sites: http://sg.php.net/manual/en/ref.dom.php (v5) http://sg.php.net/manual/en/ref.domxml.php (v4)
  23. Shouldn't that be `a_id`, not 'a_id' ? Edit: You should edit dbarray() so it checks for errors. Otherwise you will have more problems like this in future. Edit2: Where's the call to mysql_query()? What I meant above is that you should check for errors from mysql_query()
  24. It is breaking up the page by the "(" and ")" characters. It knows that there are a fixed number of "(" before the latitude and longitude turn up. It's a very un-sophisticated method Try printing out out each variable used during the processing to get a better understanding of what's going on. Particularly print out $page (use var_dump($page))
  25. Ok.. so it's 3 right from the start. Well that url looks fine to me. How about $_GET['target_id'], is that set to 2 or 3? Edit: 5 hours well-spent.. you won't make the same mistake again
×
×
  • 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.