Function not work
#4

First of all, the random() function generates a pseudo random number between 0 and max-1. So the only possible outputs for random(2) are 0 and 1. And therefore the "randomphonenumber" can only be 1 or 2.

Furthermore, this is a pretty horrid way to go about querying the database. You only need to check if the randomly generated number exists, which is as simple as querying the "PhoneNumber" column directly (use it in the WHERE component).

And thirdly, if you just want to get a count of something (e.g. number of players) use the count() aggregate function in a query rather than num_rows. A select star carries over ALL the data, which puts an unnecessary strain on the system. This will also get progressively worse as the database grows. A count() on the other hand will always just return one single number.
Reply


Messages In This Thread
Function not work - by Mister0 - 06.08.2016, 20:41
Re: Function not work - by Freaksken - 06.08.2016, 21:04
Re: Function not work - by Mister0 - 06.08.2016, 21:15
Re: Function not work - by Vince - 06.08.2016, 21:39
Re: Function not work - by Freaksken - 06.08.2016, 22:04
Re: Function not work - by Mister0 - 07.08.2016, 13:46

Forum Jump:


Users browsing this thread: 1 Guest(s)