/    Sign up×
Community /Pin to ProfileBookmark

Inserting into multiple tables

I can’t seem to insert data into multiple tables

User(User_ID, Email, First_Name, Second_Name, Gender, Age, Password, Title)
Workout(Workout_ID, User_ID, Date)
Exercise(Exercise_ID, Name, Description, Image)
Workout_Exercises(Workout_Exercises_ID, Workout_ID, Exercise_ID, Reps, Sets)

Now when I go to do this:

[CODE]$insert1 = mysql_query(“INSERT INTO exercise(Name) values(‘$exercise1’);”);

$insert2 = mysql_query(“INSERT INTO workout_exercises(Reps, Sets) values($reps1, $sets1);”);[/CODE]

The exercise gets inserted but the reps and sets do not get inserted into the workout_exercises table. I think this has something to do with the Exercise_ID and the Workout_ID but I am really not sure.

Please someone help!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@jr_wramirezMay 11.2012 — remember the basic of coding:

always check the syntax if you omit single qoute, semi colon, etc.

in your case

$insert1 = mysql_query("INSERT INTO exercise(Name) values('$exercise1')[COLOR="Red"][B];[/B][/COLOR]");
>remove the semi colon

$insert2 = mysql_query("INSERT INTO workout_exercises(Reps, Sets) values([COLOR="Red"][B]'[/B][/COLOR]$reps1[COLOR="Red"][B]'[/B][/COLOR],[COLOR="Red"][B]'[/B][/COLOR] $sets1[COLOR="Red"][B]'[/B][/COLOR])[COLOR="Red"][B];[/B][/COLOR]");

>enclose your values in single quote

>remove semi colon



regards
×

Success!

Help @Bruceorange spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...