Twister1004 Posted November 26, 2008 Share Posted November 26, 2008 Hey everyone! I've been having a little trouble with this script, however I don't see why. I've ran tests but I've not received an error. It also doesn't want to work. Objective: Figure out why this Query wont work. Problem: $loginchange = mysql_query("UPDATE `1amyth_account` SET `loggedin` = '1' WHERE `username` = '$username'"); You can see I'm trying to UPDATE the table "loggedin" to 1 from 0 showing the account is logged in and can be tracked. Then I'm going to, later, turn it back to 0 when they log out. Whole Code <?php error_reporting(E_ALL); include("inc/config2.php"); if (isset($_POST['username'])) { $username = mysql_real_escape_string(trim($_POST['username'])); $password = mysql_real_escape_string(trim($_POST['password'])); /*-------------------------------Attempt to Login--------------------------------------------*/ $sql = mysql_query("SELECT * FROM `lamyth_account` WHERE `username` = '$username' AND `password` = '$password' LIMIT 1") or die("Contact the Admin with this id / code " . mysql_error()); if (mysql_num_rows($sql) == 0) die("Invalid Username or Password. <br/>Please go back and re-enter your information."); while ($data = mysql_fetch_assoc($sql)) { if (!isset($_SESSION['login_id'])) { $_SESSION['login_id'] = $data['accountid']; $_SESSION['login_user'] = $data['username']; $_SESSION['login_pass'] = $data['password']; $lastlogin = mysql_query("UPDATE `lamyth_account` SET `last_login`= NOW() WHERE `username` = '$username'"); $loginchange = mysql_query("UPDATE `1amyth_account` SET `loggedin` = '1' WHERE `username` = '$username'"); } else break; } } @$user = $_SESSION['login_id']; if (isset($_SESSION['login_user'])){ ?> <div style=""> <?php echo "Welcome, {$_SESSION['login_user']}.";?> <br/> <div id="logout_in"> <img src="images/logout.png" onClick="parent.window.location = './logout.php'" /> </div> </div> <?php } else{ ?> <form method="POST" action=""> <table> <tr> <td>Username:</td><td><input type="text" name="username" id="username" maxlength="20" size="10" /></td></tr> <tr><td>Password:</td><td><input type="password" name="password" id="password" maxlength="20" size="10" /></td></tr> </table> <div id="logout_in"> <input type="image" src="images/loginchange.png" name="submit" /> <?php } ?> </div> </form> Any hints, tips, posts, reading, etc helps. Thanks =). Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 26, 2008 Share Posted November 26, 2008 First: $loginchange = mysql_query("UPDATE `1amyth_account` SET `loggedin` = '1' WHERE `username` = '$username'")or die(mysql_error()); Second: echo out all your variables that you want to use in that query before and after the query. Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted November 26, 2008 Author Share Posted November 26, 2008 Well, apparently the table doesn't exist.... lol. I have no idea why it wouldent if the above table worked xD. Exact error code: Table 'lamyth2.1amyth_account' doesn't exist And ideas? Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted November 26, 2008 Author Share Posted November 26, 2008 Well, Honestly I don't know what I just did, because I didn't really do anything, and it just.... worked O_o.creepy, if you ask me. Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted November 26, 2008 Author Share Posted November 26, 2008 Ok Solution! NEVER USE "_" IN DATABASE TABLES, lol. 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.