Page 1 of 1
PHP/Mysql browser based game
Posted: Tue Apr 10, 2012 7:31 pm
by cxn
Hey guys
I'm working on my own little project, just created login / registration page! For now my intent is to build a crimes page, steal page.. basic mafia page stuff to be honest. Before I tackle these pages I have a few questions:
I noticed in Hall's tutorials that he doesn't use PDO or OOP. I know a bit of PDO so I'm going to try and integrate this in my programming (also for security reasons). However, I'm not at all familiar with OOP and was wondering if it's the standard nowadays? If not, what would you recommend to have simplified scripts? A lot of functions I bet?
Next I want to know if it's smart to make queries every time money changes (or exp, ..) or would it be best to store this in a variable until a session expires? I bet this isn't smart since a session can expire because a user has been idle for too long, instead of pressing the log out button (which would store the vars in the database (updating cash, exp etc)).
I got some more questions I think but I have no clue for a sec, too baked my bad! Hope this is clear

Thanks
Re: PHP/Mysql browser based game
Posted: Tue Apr 10, 2012 8:45 pm
by Chris
Don't store important things in sessions. They can sometimes mess around, especially if the client deletes their cookies or whatnot. OOP I guess is the standard nowadays.
You might want to check out an MVC framework if you are going down the OOP route.
Re: PHP/Mysql browser based game
Posted: Tue Apr 10, 2012 8:59 pm
by cxn
Chris wrote:Don't store important things in sessions. They can sometimes mess around, especially if the client deletes their cookies or whatnot. OOP I guess is the standard nowadays.
You might want to check out an MVC framework if you are going down the OOP route.
Ok I see, so the best thing to do is to do queries, and each time?
I just googled MVC framework, looks demotivating haha! I'll try to read up tomorrow. By the way, do you also suggest PDO above prepared statements with mysqli or regular mysql?
Thanks
Re: PHP/Mysql browser based game
Posted: Wed Apr 11, 2012 2:56 am
by Jackolantern
MySQLi > MySQL extensions, everytime, for everything. MySQLi extension is the far more advanced, efficient and secure successor to MySQL extension. If the MySQL extension had not been so important to basically all PHP development, it would basically be deprecated (marked for people to stop using, and eventual removal) today. Due to its importance, however, it will likely never be deprecated as to not break older software.
Re: PHP/Mysql browser based game
Posted: Wed Apr 11, 2012 6:25 am
by Verahta
how do you know if you are using the old MySQL or newer MySQLi?
Re: PHP/Mysql browser based game
Posted: Wed Apr 11, 2012 9:24 pm
by brockfanning
If you're using PHP, you should be able to see that info in a phpinfo page, like:
Re: PHP/Mysql browser based game
Posted: Wed Apr 11, 2012 10:53 pm
by Jackolantern
Well, both are always available in all semi-current PHP versions and newer. If you are using the
older MySQL extension, you will be using procedural functions like:
You can instead use the newer
MySQLi extensions, and the procedural functions will look like:
Re: PHP/Mysql browser based game
Posted: Sat Apr 14, 2012 11:31 am
by Verahta
Thanks guys, I checked my PHP Info page and I do seem to have both:
MySQL Support enabled
MysqlI Support enabled
mysqlnd enabled
PDO Driver for MySQL enabled
And sorry for taking your thread slightly off-topic OP!
Re: PHP/Mysql browser based game
Posted: Sun Apr 15, 2012 12:22 am
by Xaleph
PDO is actually the way to go. In fact, MySQLi is deprecated as of yet. Instead, you should use PDO. PDO is the "true" OO way to go and it`s the safer bet over MySQL(i). However, as it turns out, more then 60% of all PHP developers working with MySQL still just write regular queries using the default MySQL functions.
Re: PHP/Mysql browser based game
Posted: Sun Apr 15, 2012 3:04 am
by Jackolantern
Actually, MySQLi stacks up decently well to PDO and it is not going to be deprecated in the near future, as can be seen on
PHP's API comparison matrix. I usually recommend MySQLi right off the bat here because it can be used procedurally or OO, which makes it much more appropriate for beginning programmers.
And honestly, most advanced PHP coding is going to be done with an ORM solution or at least a framework which will take the responsibility away from directly interacting with the database extension to create a generic interface.