FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » PHP & MYSQL OVERHEAD / INTERUPTION PROBLEM
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP & MYSQL OVERHEAD / INTERUPTION PROBLEM [message #36083] Sat, 03 March 2007 03:54 Go to next message
billyspcs is currently offline  billyspcs   United States
Messages: 2
Registered: March 2007
Location: NY
Karma: 0
Junior Member
See the reply below:

Call a rose a rose it smells good... call a rose a flower it smells good...

[Updated on: Mon, 05 March 2007 16:43]

Report message to a moderator

Re: test [message #36084 is a reply to message #36083] Sat, 03 March 2007 04:04 Go to previous message
billyspcs is currently offline  billyspcs   United States
Messages: 2
Registered: March 2007
Location: NY
Karma: 0
Junior Member
1) Background:
Basically I plan to develop a gaming text/picture based game this spring using PHP. However I am running into a few major problems I need answered. I want this page to be as quick loading as possible – even if say a thousand people are accessing any given page at one time. These are my plans:

All the user info will be stored in a MySQL table called accounts:

Id username passwordMD5 points item1 item2 item3 item4 item5

Now every page loaded will have to do this:

a) check to see cookie is set
b) Load row of table accounts where username of cookie is equal to the username in MySQL and passwordMD5 of the cookie is equal to passwordMD5 of the MySQL
c) Possibly update a MySQL data value for this user…
d) Display this PHP page’s content


2) First Question:
As you can see this seems like a lot of unnecessary MySQL accessing. But lets say any given php script will be setting item1 equal to weaponID of 5 or changing points equal to points minus 50
…then obviously the script will need the MySQL points value…

I guess what I’m wondering is if there exists a way of loading the accounts row once for each user and then have it be available on every php script on the server. Why should it have to reload at the beginning of every script if every script uses it.

3) Second Question:
Let’s say I will have a weapons shop page on the site… weapons.php – Where that page will display a table called weapons with the ability for the user to click a weapon and buy it…

php file - buyWeapon.php
a) check to see cookie is set
b) Load row of table accounts where username of cookie is equal to the username in MySQL and passwordMD5 of the cookie is equal to passwordMD5 of the MySQL

c) check to see points on accounts table > cost on weapons table (MySQL query)
d) take item out of table weapons… or decrease # of weapons in table (MySQL query)
e) update accounts for user so that item1 is equal to weapons(id) (MySQL query)
f) display you bought the weapon

So my problem with this script is that a user anxious to buy every single item often clicks an item ten times in a second by holding down the enter key. So this causes the server to get overwhelmed and somehow give the person the item but not update the users points equal to points minus weapons(cost)

I have no clue how this is even possible… especially since the update for points in table accounts happens before the update of item1 in table accounts which actually gives them the item

I have thought it might be possible to put all request into a queue for later processing, but that would make the game boring if you had to wait a day for an item buy… ?I just don’t know…

I am thanking all in advanced for any help…
My email is whispewd190(at)potsdam(dot)edu


Call a rose a rose it smells good... call a rose a flower it smells good...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: php contact form - remove required fields
Next Topic: problem with arrays/loops in PHP and javascript
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Dec 18 04:12:54 GMT 2024

Total time taken to generate the page: 0.04949 seconds