GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Sep-2006, 01:06
eb_webdeveloper eb_webdeveloper is offline
New Member
 
Join Date: Sep 2006
Posts: 3
eb_webdeveloper is on a distinguished road
Angry

registering new users, inserting into multiple tables


I need to insert new customers information into multiple mysql tables when I register them. I have this code, and the first part works, but the second function does not, what are some possible solutions? I have set up all of the variables and they work properly.

session.php is where the information is stored in the database
PHP Code:

$database->addNewUser($subuser, md5($subpass), $subulevel, $subemail);
       
       if(isset($subuser)) {
       
          $user_id = mysql_insert_id();
       
          $database->addNewBroker($user_id, $subname, $subaddress, $subcity, $substate, $subzip, $subcontact, $subphone, $subfax);
          
          return 0;  //New user added succesfully
       }
       else{
          return 2;
       } 



database.php is linked w/ session.php
PHP Code:

function addNewUser($username, $password, $userlevel, $email){
      $time = time();
      $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', 0, '$userlevel', '$email', $time)";
      return mysql_query($q, $this->connection);
   }
   function addNewBroker($user_id, $name, $address, $city, $state, $zip, $contact, $phone, $fax){
      $q = "INSERT INTO tbl VALUES ('$user_id', '$name', '$address', '$city', '$state', '$zip', '$contact', '$phone', '$fax')";
      return mysql_query($q, $this->connection);
   } 



I honestly do not know what I'm doing wrong
  #2  
Old 20-Sep-2006, 12:29
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: registering new users, inserting into multiple tables


Is 'tbl' a real table?
What is the sql error message?
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 22-Sep-2006, 08:14
eb_webdeveloper eb_webdeveloper is offline
New Member
 
Join Date: Sep 2006
Posts: 3
eb_webdeveloper is on a distinguished road

Re: registering new users, inserting into multiple tables


It is a real table, and there is no mysql error message, it just acts like I didn't even write any code, you know?

I'm so clueless
  #4  
Old 22-Sep-2006, 09:26
eb_webdeveloper eb_webdeveloper is offline
New Member
 
Join Date: Sep 2006
Posts: 3
eb_webdeveloper is on a distinguished road

Re: registering new users, inserting into multiple tables


I figured it out, I was testing my tables and databases and I typed in the wrong database name, I feel even more retarded now, but at least its fixed
  #5  
Old 22-Sep-2006, 10:10
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: registering new users, inserting into multiple tables


I have done this quite a few times myself. At least I must thank you for coming back and telling us what happened.

Nowadays, I always write my queries like this:

PHP Code:

<?php

$sql = "SELECT * FROM `some_table` WHERE `something`=99";
if( $result=@mysql_unbuffered_query($sql, $conn) )
{
  // do something with the row.
}
else
{
  trigger_error( $sql."\n".mysql_errno($conn)." - ".mysql_error($conn), E_USER_ERROR );
}


Of course I log my PHP errors to a file, so I don't worry about the error messages being shown on the web pages because they are not.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linker errors with multiple file progam nkhambal C Programming Language 2 24-Apr-2005 03:37
Customising SMS sending script via e-mail gateway for multiple users jrobbio MySQL / PHP Forum 4 29-Sep-2003 13:49

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:43.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.