thenewperson Posted November 6, 2009 Share Posted November 6, 2009 Trying to add this code into database but i dont understand this script that well and keep failing. Trying to add $folder into data base field folder where the username is when they register $folderid = md5(uniqid(rand())); $folder = substr($id, 0, 10); function addNewUser($username, $password, $email){ $time = time(); $database->updateUserField($this->username, "folder", $this->$folder); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)"; return mysql_query($q, $this->connection); } full login system is here http://evolt.org/node/60384 Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 6, 2009 Share Posted November 6, 2009 Wow that is one moldy tutorial. It uses addslashes and stripslashes instead of mysql_real_escape_string. You are waaay off base with what you're doing. To tell you how to fix it entirely, i'd need to understand more about what the folder value is. Is this a new column you added to the Users table? If so, you'd simply add that as a param to this method, and to the insert. Needless to say your current code won't work, not only because of the numerous syntax errors and misunderstanding of $this->, but also because if you look at what you're doing -- how could you attempt to update a value in a row, where you haven't even inserted the row for the user yet? Quote Link to comment Share on other sites More sharing options...
thenewperson Posted November 6, 2009 Author Share Posted November 6, 2009 Typed the wrong line in on accident from something else this is what it was function addNewUser($username, $password, $email){ $time = time(); $folderid = md5(uniqid(rand())); $folder = substr($id, 0, 10); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, $folder)"; return mysql_query($q, $this->connection); } Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 6, 2009 Share Posted November 6, 2009 You have a pretty obvious error with your temp variables. There's really no reason to make a temp variable called folderid, just so you can substr() it. Do it in one line. Again -- this assumes that you have added a folder column to the users table and it's the last column after the time. function addNewUser($username, $password, $email){ $time = time(); $folder = substr(md5(uniqid(rand())), 0, 10); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, $folder)"; return mysql_query($q, $this->connection); } Quote Link to comment Share on other sites More sharing options...
thenewperson Posted November 6, 2009 Author Share Posted November 6, 2009 ty, got it to work + i feel stupid now for how simple should of been lol^^ Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 6, 2009 Share Posted November 6, 2009 ty, got it to work + i feel stupid now for how simple should of been lol^^ No worries, that is what this forum is for -- helping people who are actively trying to code php. 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.