PHP Tips and Tricks

C++, C#, Java, PHP, ect...
mrmajic
Posts: 117
Joined: Sat Jun 27, 2009 9:37 am

Re: PHP Tips and Tricks

Post by mrmajic »

another thing .. i have a logins table .. and its set to 15 .. and everything i run this line:

$updateplayer="update players set logins=$logins-1 where name='$player'";


it minus's 1 login from the table ,.. what am i doing wrong .. it doesnt work... should this line work?
Mr Majic...

Current Project: http://www.deltarealm.net
feedback welcome.
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: PHP Tips and Tricks

Post by hallsofvallhalla »

logins is not a variable, take out the $

$updateplayer="update players set logins=logins-1 where name='$player'";

also i am assuming you have the query line on the next line?
mrmajic
Posts: 117
Joined: Sat Jun 27, 2009 9:37 am

Re: PHP Tips and Tricks

Post by mrmajic »

oh yeah . .. the query line .. now it works :) first it was forgetting ; and } now its the query line ..
Mr Majic...

Current Project: http://www.deltarealm.net
feedback welcome.
mrmajic
Posts: 117
Joined: Sat Jun 27, 2009 9:37 am

Re: PHP Tips and Tricks

Post by mrmajic »

so whats the cons to using $_SESSION's to hold all ya variables.. ??
Mr Majic...

Current Project: http://www.deltarealm.net
feedback welcome.
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: PHP Tips and Tricks

Post by Noctrine »

They are all in sessions. What happens when someone clears them.
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
mrmajic
Posts: 117
Joined: Sat Jun 27, 2009 9:37 am

Re: PHP Tips and Tricks

Post by mrmajic »

theonly way to clear sessions from the users point is to logout/close brower .. they only have to log back in .. as long as ya updating the database with the current $_SESSION['variable'], then its ok isnt it??
Mr Majic...

Current Project: http://www.deltarealm.net
feedback welcome.
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: PHP Tips and Tricks

Post by Noctrine »

A session is still a cookie. You can delete individual cookies in the browser quite easily.
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
xezero
Posts: 47
Joined: Fri Jun 19, 2009 1:35 am

Re: PHP Tips and Tricks

Post by xezero »

this is a good read for those trying to squeeze the extra performance out of php:

http://www.phpbench.com/
Post Reply

Return to “Coding”