Page 1 of 1

problem while connecting php to mysql

Posted: Thu Apr 02, 2009 9:43 am
by srichandar
Hi all,

Am new to php,
i created a registration form using php.

i have to insert the values of the form in two mysql db tables simultaneously.

i created a table called "accountdetails" in that id,username and password will alone stored.

id is primary key and auto increment.

next i created a table called "userdet" in this i used account details's id as a foregin key.

i have to insert the values in "userdet" based on the primary key value of "accountdetails"

while inserting "accountdetails" table is updated successfully but not the "userdet" table.

please help me with this regards,

thanks in advance,
sridhar

Re: problem while connecting php to mysql

Posted: Thu Apr 02, 2009 11:54 pm
by jaoudestudios
What is your query so far?

Re: problem while connecting php to mysql

Posted: Fri Apr 03, 2009 5:28 am
by srichandar
while inserting into table values updated successfully in one table and not in the other..

Re: problem while connecting php to mysql

Posted: Fri Apr 03, 2009 5:47 am
by jaoudestudios
srichandar wrote:while inserting into table values updated successfully in one table and not in the other..
That is not a mysql query?

Re: problem while connecting php to mysql

Posted: Fri Apr 03, 2009 6:19 am
by srichandar
ACCOUNT_INFO table

Code: Select all

CREATE TABLE IF NOT EXISTS ACCOUNT_INFO (
  USERID int(5) NOT NULL auto_increment,
  USER_NAME varchar(50) default NULL,
  PASSWORD varchar(50) default NULL,
  EMAIL varchar(50) default NULL,
  VALIDITY_STATUS varchar(5) NOT NULL default 'NO',
  PRIMARY KEY  (USERID)
)
USERPROFILE table

Code: Select all

CREATE TABLE IF NOT EXISTS USER_PROFILE (
  FI_USERID int(5) NOT NULL default '0',
  FIRST_NAME varchar(50) default NULL,
  MIDDLE_NAME varchar(50) default NULL,
  LAST_NAME varchar(50) default NULL,
  ADDRESS1 varchar(50) default NULL,
  ADDRESS2 varchar(50) default NULL,
  CITY varchar(25) default NULL,
  OTHER_CITY varchar(25) default NULL,
  COUNTRY varchar(25) default NULL,
  PHONE_RES varchar(25) default NULL,
  PHONE_OFF varchar(25) default NULL,
  MOBILE varchar(25) default NULL,
  EXPERIENCE varchar(6) default NULL,
  KEY_SKILLS varchar(255) default NULL,
  GENDER varchar(10) default NULL,
  DATE_OF_BIRTH date default NULL,
  RESUME_NAME varchar(100) default NULL,
  CURRENT_INDUSTY_TYPE varchar(255) default NULL,
  CURRENT_FUNCTIONAL_AREA varchar(255) default NULL,
  MAIL_ADDRESS varchar(250) default NULL,
  DEFICENCY text,
  DESCRIPTION1 text,
  DESCRIPTION2 text,
  RESUME_DATA text,
  PREFERED_LOCATION text,
  SSLC_PERCENTAGE varchar(25) default NULL,
  HSC_GROUP varchar(50) default NULL,
  HSC_PERCENTAGE varchar(50) default NULL,
  USER_STATUS varchar(5) default NULL,
  RESUME_FILE varchar(255) default NULL,
  PRIMARY KEY  (FI_USERID),
  FOREIGN KEY (FI_USERID) REFERENCES ACCOUNT_INFO(USERID)  
  ON UPDATE CASCADE 
  ON DELETE CASCADE
);
and finally my query is:

Code: Select all

"INSERT INTO ACCOUNT_INFO (USER_NAME, PASSWORD, EMAIL) VALUES ('".$user_name."','".$pass_word."','".$email_add."')"
and

Code: Select all

"INSERT INTO USER_PROFILE (FI_USERID, FIRST_NAME,CITY, OTHER_CITY, COUNTRY) VALUES ('".$username."','".$city."','".$city_other."','".$user_country."')"
in this values are updated in ACCOUNT_INFO and not in USERPROFILE

Re: problem while connecting php to mysql

Posted: Fri Apr 03, 2009 8:05 am
by susrisha
have you tried to print out the error for syntax??

Code: Select all

 
$query = "YOUR MYSQL QUERY";
if(!mysql_query($query))
{
echo mysql_error();
}
 
 
Try to put these for each of the query that you are running and see if it comes up with an error. Do post us the error so that we can help you out on this.