jelco Posted May 1, 2004 Share Posted May 1, 2004 In the script below it queries a database several times to login a user and change some of the fields in the users row. It logs the user in fine but doesn't seem to want to update the 'money' and 'experince' fields. So could someone just take a quick look over the code cause its probaly somthing I'm just missing now. <?php #Load Community Settings require("comm/config.php"); $user1 = $_POST['user']; #Username from login form $pass1 = $_POST['pass']; #Password from password form $date = date('Ymd'); #Current Date settype($date,"integer"); if (($user == NULL) OR ($pass == NULL)){ include("login.php"); print "<p align='center'><font face='" . $fface . "'>Invaild Username/Password</font></p>"; } else { $db =mysql_connect($host,$user,$pass) or die(mysql_error()); mysql_select_db($dbase,$db); $sql = mysql_query("SELECT * FROM users WHERE username='$user1'",$db) or die(header("Location:login.php")); if ($data = mysql_fetch_assoc($sql)) { $password = $data['password']; $username = $data['username']; $jobs = explode("|",$data['jobs']); $lastaccess = $data['last']; settype($lastaccess, "integer"); } if ($password == $pass1) { #Set Cookie For User In Community $comm = $username . "|" . $password; setcookie("comm",$comm); #Updates The User To Show He/She Is Online mysql_query("UPDATE users SET place='1',last='$date' WHERE username = '$user1'",$db); #Gives User His/Her Salary if ($lastaccess < $date){ $Sexp = 0; $Smoney = 0; $i = 0; while($i < count($jobs)){ $sql = mysql_query("SELECT salary FROM jobs WHERE title='$jobs[$i]'",$db) or die(mysql_error()); if ($data = mysql_fetch_assoc($sql)){ $salary = explode("|",($data['salary'])); settype($salary,"integer"); if ($salary[0] > $Smoney){ $Smoney = settype($salary[0],"integer"); } if ($salary[1] > $Sexp){ $Sexp = settype($salary[1],"integer"); } } $i++; } $sql = mysql_query("SELECT money,experince FROM users WHERE username='$user1'",$db) or die(mysql_error()); if ($data = mysql_fetch_assoc($sql)){ $CurrentMoney = $data['money']; $CurrentExp = $data['experince']; } $Sexp = $Sexp + $CurrentExp; $Smoney = $Smoney + $CurrentMoney; mysql_query("UPDATE users SET money='$Smoney',experince='$Sexp' WHERE username = '$user1'",$db); } header("Location:comm/index.php"); } else { include("login.php"); print "<p align='center'><font face='" . $fface . "'>Invaild Username/Password</font></p>"; } } ?> Thankz Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.