Anxious Posted April 12, 2009 Share Posted April 12, 2009 When a user registers, the normal registration works, and goes into the table USERS However, I also have a table called PROFILE which only puts the Username, Password and Email Address value in. When I test register, it succeeds, however, the database table PROFILE doesn't get any inputs. Table USERS does, so I don't understand why its not inserting the values into that database. Here is the bit of my session.php code (directs to database.php to insert values) <?php /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the */ else{ if($database->addNewUser($subuser, md5($subpass), $subemail, $subday, $submonth, $subyear, $sublocation, $subgender)){ if($database->addNewProfile($subuser, md5($subpass), $subemail)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass,$sublocation,$subgender); } return 0; //New user added succesfully } }else{ return 2; //Registration attempt failed } ?> if($database->addNewUser($subuser, md5($subpass), $subemail, $subday, $submonth, $subyear, $sublocation, $subgender)){ if($database->addNewProfile($subuser, md5($subpass), $subemail)){ It shows addNewUser, which that bit works, that puts the user into the USER database. addNewProfile, is the bit that doesn't work. Here is database.php (addNewUser and addNewProfile) [code] <?php function addNewUser($username, $password, $email, $day, $month, $year, $location, $gender){ $time = date("F j, Y, g:i"); $dob = $_POST['day'] . "/" . $_POST['month'] . "/" . $_POST['year']; /* 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', '$ulevel', '$email', '$time', '$location', '$dob', '$gender', '0')"; return mysql_query($q, $this->connection); } function addNewProfile($username, $password, $email){ $q = "INSERT INTO ".TBL_PROFILE." VALUES ('$username', '$password', '$email', '$slogan', '$profilelocation', '$schooljob', '$status', '$likes', '$dislikes', '$music')"; return mysql_query($q, $this->connection); } ?> Anybody know why it isn't working for table PROFILE ? Thanks. Link to comment https://forums.phpfreaks.com/topic/153728-solved-putting-values-into-two-database-tables-problem/ Share on other sites More sharing options...
HokieTracks Posted April 12, 2009 Share Posted April 12, 2009 Why don't you just have all of the profile database data in the users database? Then when you need to setup the profile just use the specific data you need out of users. I don't really think two databases is necessary. Link to comment https://forums.phpfreaks.com/topic/153728-solved-putting-values-into-two-database-tables-problem/#findComment-807879 Share on other sites More sharing options...
Anxious Posted April 12, 2009 Author Share Posted April 12, 2009 It's not not nessecary, I did include it all into users, which gave me problems, the values for the profile, always ended up in the wrong part on the database, also, I couldn't get it to display the values when people view the profile. So I thought, having smaller database tables, would make it alot easier. Link to comment https://forums.phpfreaks.com/topic/153728-solved-putting-values-into-two-database-tables-problem/#findComment-807885 Share on other sites More sharing options...
Anxious Posted April 12, 2009 Author Share Posted April 12, 2009 Would anyone know what I've done wrong. Thanks. Link to comment https://forums.phpfreaks.com/topic/153728-solved-putting-values-into-two-database-tables-problem/#findComment-807905 Share on other sites More sharing options...
MasterACE14 Posted April 12, 2009 Share Posted April 12, 2009 if it is 2 different databases then I believe you can change the queries from... this... INSERT INTO ".TBL_USERS." to this... INSERT INTO `database1`.`".TBL_USERS."` and this... INSERT INTO ".TBL_PROFILE." to this... INSERT INTO `database2`.`".TBL_PROFILE."` Link to comment https://forums.phpfreaks.com/topic/153728-solved-putting-values-into-two-database-tables-problem/#findComment-807938 Share on other sites More sharing options...
Anxious Posted April 12, 2009 Author Share Posted April 12, 2009 I sorted it thanks, it's the tables. 6 Hours of work, all I had to do was look at constants.php (which has the database details and tables to access) and put in the the definition for the database table PROFILE. Link to comment https://forums.phpfreaks.com/topic/153728-solved-putting-values-into-two-database-tables-problem/#findComment-807990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.