problem while connecting php to mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
srichandar
Forum Newbie
Posts: 6
Joined: Thu Apr 02, 2009 9:36 am

problem while connecting php to mysql

Post 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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: problem while connecting php to mysql

Post by jaoudestudios »

What is your query so far?
srichandar
Forum Newbie
Posts: 6
Joined: Thu Apr 02, 2009 9:36 am

Re: problem while connecting php to mysql

Post by srichandar »

while inserting into table values updated successfully in one table and not in the other..
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: problem while connecting php to mysql

Post 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?
srichandar
Forum Newbie
Posts: 6
Joined: Thu Apr 02, 2009 9:36 am

Re: problem while connecting php to mysql

Post 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
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: problem while connecting php to mysql

Post 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.
Post Reply