Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,157,756 members, 7,834,542 topics. Date: Monday, 20 May 2024 at 04:33 PM |
Nairaland Forum / Science/Technology / Webmasters / Php Quiz (win While You Answer This) (1381 Views)
If You Answer This IQ Test, Then You Can Be A Web Developer & A Genius / Most Confusing And Simple Maths Quiz / Very Easy Html/php Quiz :) (2) (3) (4)
Php Quiz (win While You Answer This) by Nobody: 11:31am On Mar 30, 2008 |
Let us look at random number generation please create a database and run this query CREATE TABLE randomnumbers ( <?php Study the codes above carefully and answer my questions 1. Is the above code correct? if no, tell us the mistake (please don't post the correction, just tell us) 2. state the intention of the code if your response to question 1 is no, please correct it and run it on your computer, after running it, copy the first 5 generated numbers and save them in a txt file, empty the database and insert the 5 numbers you saved into the database manually, then run the script again. (note: don't copy the serial numbers on the left o, its meant to let you know how many numbers you have generated) 3. tell us why you keep getting a mysql error about a duplicate entry each time you run the script, even when you are nothing close to 99,000 and why the duplicate entry happens to be 1 of the five numbers you inserted manually now lets move to the most interesting part of where i am driving to 4. why is it that each time you refresh the page, you keep getting a duplicate entry error even when there are still much numbers available. and why is the generated number the next number in the database table, and the next and next , be ready to burn time on this as the reward is 1 year hosting and domain account Note: 999,999 is the maximum possible number and you are not even getting close to it although if you ask a question that shows you dont understand PHP, i might not answer it but still feel free to ask questions sha |
Re: Php Quiz (win While You Answer This) by naijafan(m): 11:46am On Mar 30, 2008 |
@webdezzi I dont do PHP but from what I can see up there, if you're getting the errors you mentioned in your questions, then you may have to seed the random number generator. The rand function in most programming languages is basically a pseudo-random number generator which uses some complicated arithmetic to make the number generated seem random. plus the basic number generated is always between 0 and 1. This is then adjusted to fit in the actual ranges required by the developer. Seeding the RNG simply improves on the seeming randomness of its results. |
Re: Php Quiz (win While You Answer This) by Nobody: 7:59pm On Mar 30, 2008 |
your point noted, seed it and lets see what comes up (i just wish you do php) as of PHP 4.2.0, you dont have to seed rand() because the php guys already realized that you will always want it seeded so they ve already done that for you. (its in the php5 manual) that was intelligent but still nothing close to whats happening. |
Re: Php Quiz (win While You Answer This) by naijafan(m): 8:46pm On Mar 30, 2008 |
webdezzi: LOL. Then your prize is out of ma reach then |
Re: Php Quiz (win While You Answer This) by Nobody: 7:13pm On Mar 23, 2009 |
Free hosting expired Today. lol |
Re: Php Quiz (win While You Answer This) by Nobody: 9:23pm On Mar 23, 2009 |
Waiting to see the answer to this, today was a very hectic day, i doubt if i can write any codes tonight. . . |
Re: Php Quiz (win While You Answer This) by quadrillio(m): 1:43pm On Mar 24, 2009 |
I will I could but so broke I can't even PAY attention, so I got to work for pay I'll try it later though |
Re: Php Quiz (win While You Answer This) by Nobody: 7:12pm On Mar 24, 2009 |
How come nobody has attempted this quiz yet? lemme disappoint by not making an attempt too. . . By the way, @poster, what is the prize for winning? maybe ppl will be encouraged? |
Re: Php Quiz (win While You Answer This) by ztyle(m): 7:18pm On Mar 24, 2009 |
dhtml:The winning price is "Kulikuli" wether u like it or not. |
Re: Php Quiz (win While You Answer This) by Nobody: 8:21pm On Mar 24, 2009 |
this was posted last year and usefull hint has been mention on another thread. Thats why ztyle is offering that |
Re: Php Quiz (win While You Answer This) by yawatide(f): 8:36pm On Mar 24, 2009 |
Since everyone seems to be chickening out on this (what a disappointment. I had so much faith in some on here. You know who you are), I will add a thing or 2: 1. Is the above code correct? if no, tell us the mistake (please don't post the correction, just tell us) There is more than one mistake, granted it may not be what you are looking for: a) No mysql_close() b) Little or no error checking 2. state the intention of the code To generate random numbers, I presume. 3) Sorry but I don't have time to create databases/tables/run code but I will say this, this line is giving me craw-craw just looking at it: $conCatRand="$randnumb1$randnumb2$randnumb3$randnumb4$randnumb5$randnumb6$randnumb7$randnumb8$randnumb9"; Even if it is correct, though I know it's not, I would personally flog whoever came up with this with a koboko soaked in 5 different kinds of pepper, then starched to make it hard. That's all from me on this one. sorry but again, I am a very lazy person and don't see myself running any code |
Re: Php Quiz (win While You Answer This) by Nobody: 5:09pm On Mar 25, 2009 |
yawa-ti-de: lol thats funny well, mysql_close() may not be called, it is ok as connections are closed at the end of the script execution as in d php manual anyway, you are still correct about this $conCatRand="$randnumb1$randnumb2$randnumb3$randnumb4$randnumb5$randnumb6$randnumb7$randnumb8$randnumb9";in php, you can concatenate variables with nothing as long as they are inside double quotes Thanks for the contribution, i was also expecting someone here to jump at it and devour it, well still waiting sha guys, i need a non-lazy programmer to run those sqls and scripts and tell us why we keep getting those 5hit. |
Re: Php Quiz (win While You Answer This) by Nobody: 3:13am On Mar 27, 2009 |
Well. . . . . |
Re: Php Quiz (win While You Answer This) by Nobody: 10:26am On Mar 28, 2009 |
Wondering why there are no more attempts? is it that ppl are afraid of getting corrected or torn to pieces? heh? |
Re: Php Quiz (win While You Answer This) by yawatide(f): 1:00pm On Mar 28, 2009 |
Wondering why there are no more attempts? is it that ppl are afraid of getting corrected or torn to pieces? heh?because you are yet to answer The average Nigerian doesn't lead by example. They want to follow-follow. Hopefully, you will break that trend We await. |
Re: Php Quiz (win While You Answer This) by Nobody: 2:54pm On Mar 28, 2009 |
Let them keep waiting then. . .till . . . |
Re: Php Quiz (win While You Answer This) by OmniPotens(m): 10:08am On Mar 30, 2009 |
Specifying max or min for the rand function should give a max ranged of 32768 which is still not any close to getting to 999,999. Just tried out this morning and saw that the values are at this ranged. I've tried other functions too. One thing I did to get a better value range was by using the rand(), no rand_max or rand_min. I failed this right? |
Re: Php Quiz (win While You Answer This) by Nobody: 10:12am On Mar 31, 2009 |
thanx omni. Since DHTML has decided to chicken out and wait for others, maybe i shud let the cat out ***anxiously waiting for dhtml*** |
Re: Php Quiz (win While You Answer This) by Nobody: 7:26pm On Mar 31, 2009 |
Really? so you guyz are really waiting for me to answer this? i decided to give others a chance 'cos i noticed that some other folks do not attempt the quiz, it seems to be between, me, poster, yawatide . . . as if we are the only webmasters in this place. . .let others try too. . .besides i have decided to reduce my posting of codes too Looks like my codes cause trouble sometimes . . . i will only post codes when absolutely necessary |
(1) (Reply)
Drupal 7 Webmasters! Please Answer Only This One Question / Domain & Hosting Reseller Website / Plentiplenti.com - Nigerian Jobs Aggregator
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 103 |