Jump to content

[SOLVED] Putting values into two database tables - problem


Anxious

Recommended Posts

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.

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.

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.

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."`

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.