I want people to have money on a game I'm making...
There is also a way to get more money, but the code doesn't work...
I don't get any errors... And it says what it is supposed to say, but it doesn't update the players money.
<?php
include("include/session.php");
/* Class constructor */
function MySQLDB(){
/* Make connection to database */
$this->connection = mysql_connect(localhost, root ) or die(mysql_error());
mysql_select_db(test, $this->connection) or die(mysql_error());}
$getal = rand(10,100);
if($getal <$p6+1){
$geld = rand(625,1250);
mysql_query("UPDATE users SET `money`=`money`+'$geld' WHERE 'username'='{$_session->username}'")
or die(mysql_error());
print "Successful! You got \$$geld money.";
exit;
}
else{
$geld = rand(625,1250);
mysql_query("UPDATE users SET `money`=`money`+'$geld' WHERE 'username'='{$_session->username}'")
or die(mysql_error());
print "Successful! You got \$$geld money.";
exit;
}
?>
I made it twice for my own reasons...
Ehm... Well it says when i go on the page: Successful! You got $1250 money. (Or less ofc - its random).
But it doesn't update my money even though im online.
This is some info:
Tablename:
users
Field names:
username
userid
money
timestamp
(There is more, but i see those as the most important).
Is there anything im doing wrong?
(Sorry for my english, and thanks in advance!)