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
problem while connecting php to mysql
Moderator: General Moderators
-
srichandar
- Forum Newbie
- Posts: 6
- Joined: Thu Apr 02, 2009 9:36 am
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: problem while connecting php to mysql
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
while inserting into table values updated successfully in one table and not in the other..
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: problem while connecting php to mysql
That is not a mysql query?srichandar wrote:while inserting into table values updated successfully in one table and not in the other..
-
srichandar
- Forum Newbie
- Posts: 6
- Joined: Thu Apr 02, 2009 9:36 am
Re: problem while connecting php to mysql
ACCOUNT_INFO table
USERPROFILE table
and finally my query is:
and
in this values are updated in ACCOUNT_INFO and not in USERPROFILE
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)
)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
);Code: Select all
"INSERT INTO ACCOUNT_INFO (USER_NAME, PASSWORD, EMAIL) VALUES ('".$user_name."','".$pass_word."','".$email_add."')"Code: Select all
"INSERT INTO USER_PROFILE (FI_USERID, FIRST_NAME,CITY, OTHER_CITY, COUNTRY) VALUES ('".$username."','".$city."','".$city_other."','".$user_country."')"Re: problem while connecting php to mysql
have you tried to print out the error for syntax??
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.
Code: Select all
$query = "YOUR MYSQL QUERY";
if(!mysql_query($query))
{
echo mysql_error();
}