$this->db->beginTransaction(); $this->db->query ('LOCK TABLES users WRITE'); $sql = 'INSERT INTO users (uname) VALUES (:uname)'; $sth = $this->db->prepare ($sql); $sth->bindParam (':uname', $uname); $sth->execute (); if ($sth->rowCount()==0) { $this->db->rollBack(); $this->db->query ('UNLOCK TABLES'); throw new Exception('<strong>Oh snap!</strong> User name is taken! Try again.'); } I set up a user in my database manually that is called "test". And when I created a user called "test2" it worked. But whenever I try to create a third user I get rowCount = 0.
The uname in the db is varchar(15).
if(isset($_POST['regUser']) && isset($_POST['regPwd']) && isset($_POST['regConfirmPwd'])) { if($_POST['regPwd'] == $_POST['regConfirmPwd'] ) { $user->newUser($_POST['regUser'], $_POST['regPwd']); } else { $user->error = "<strong>Oh snap!</strong> The passwords don't match!"; } } Send the post info to my newuser function and it stops on the first bit of code there. Any ideas?
echoyour full request before you try it in a query on the database.SQL: [41] INSERT INTO users (uname) VALUES (:uname) Params: 1 Key: Name: [6] :uname paramno=-1 name=[6] ":uname" is_param=1 param_type=2in returnuid int(PK), uname varchar(15), pwd varchar(300), fname, lname, adress etc. Had the uname as unique index but removed it for testing purposes.