PHP random string generator

To answer this question specifically, two problems: $randstring is not in scope when you echo it. The characters are not getting concatenated together in the loop. Here’s a code snippet with the corrections: Output the random string with the call below: Please note that this generates predictable random strings. If you want to create secure tokens, see … Read more

srand(time(0)) and random number generation

srand() gives the random function a new seed, a starting point (usually random numbers are calculated by taking the previous number (or the seed) and then do many operations on that number to generate the next). time(0) gives the time in seconds since the Unix epoch, which is a pretty good “unpredictable” seed (you’re guaranteed your seed … Read more

Python: Array v. List

Use lists unless you want some very specific features that are in the C array libraries. python really has three primitive data structures More on data structures here: http://docs.python.org/tutorial/datastructures.html

Generating random whole numbers in JavaScript in a specific range?

There are some examples on the Mozilla Developer Network page: Here’s the logic behind it. It’s a simple rule of three: Math.random() returns a Number between 0 (inclusive) and 1 (exclusive). So we have an interval like this: Now, we’d like a number between min (inclusive) and max (exclusive): We can use the Math.random to get the correspondent in the [min, max) interval. But, first we … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)