kryppienation Posted October 9, 2009 Share Posted October 9, 2009 I am having problems, for some reason the code below is not changing the db value, i've tried a few things and still can't get it to change. Is there anyone around who can figure out and let me know what the problem is here... The echo's work fine, displaying the username and the number 1 but for some reason the database value never changes from 0 to 1. here is the portion of code not working: $usertologin = $_SESSION["s_username"]; $loggedinid = "1"; echo $usertologin; echo $loggedinid; $setloggedinsql = 'update knusers set online = ".$loggedinid." where username = ".$usertologin."'; DB::query($setloggedinsql, "Validating user creditials"); Here is the entire code: <?php // set your infomation. include('db.php'); // connect to the mysql database server. DB::connect($DB_database); session_start(); // connect to the mysql database server. if ($_POST['username']) { // did they supply a password and username $username=mysql_real_escape_string($_POST['username']); $password=mysql_real_escape_string($_POST['password']); if ($password == NULL) { $nopass = "A password was not supplied"; } else { $checkuser = "SELECT username, wid, aid, str, def, currency, password FROM knusers WHERE username = '$username'"; $checkuser_result = DB::query($checkuser, "Validating user creditials"); $checkuser_data = mysql_fetch_array($checkuser_result); if ($checkuser_data['password'] != $password) { $loginbad = "The supplied login is incorrect, Please check your password"; } else { $_SESSION["s_username"] = $checkuser_data['username']; $_SESSION["s_weapon"] = $checkuser_data['wid']; $_SESSION["s_armor"] = $checkuser_data['aid']; $_SESSION["s_str"] = $checkuser_data['str']; $_SESSION["s_def"] = $checkuser_data['def']; $_SESSION["s_currency"] = $checkuser_data['currency']; $_SESSION["s_ipaddress"] = $_SERVER['REMOTE_ADDR']; $_SESSION["s_lastlogin"] = date('l jS \of F Y h:i:s A'); if ($_POST["returnTo"] != null) { //header("location: ../index.php"); } $usertologin = $_SESSION["s_username"]; $loggedinid = "1"; echo $usertologin; echo $loggedinid; $setloggedinsql = 'update knusers set online = ".$loggedinid." where username = ".$usertologin."'; DB::query($setloggedinsql, "Validating user creditials"); //header("location: ../index.php"); } } } ?> Any help will be greatly appriciated. Thank you. Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 9, 2009 Share Posted October 9, 2009 try this $setloggedinsql = "update knusers set online = '" . $loggedinid . "' where username = '" . $usertologin . "'"; 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.