Jump to content

[SOLVED] Problems with an update query


kryppienation

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.