ICEcoffee Posted April 21, 2006 Share Posted April 21, 2006 Hi allI can't get this INSERT command to work using a variable?I want to take the value from querying 1 table and INSERT that data into another table.<?php echo "race variables"; mysql_select_db($database_FF1, $FF1); $raceq = ('SELECT RaceID FROM races WHERE CurrentRace = 1'); $raceresult = mysql_query($raceq) or die(mysql_error()); $row = mysql_fetch_array($raceresult); // mysql_select_db($database_FF1, $FF1); $leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID) VALUES ($row['RaceID'],'9')"; mysql_query($leaderq) or die(mysql_error()); ?>Thanks for any help Quote Link to comment Share on other sites More sharing options...
shocker-z Posted April 21, 2006 Share Posted April 21, 2006 $leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID) VALUES ($row['RaceID'],'9')";needs to be$leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID) VALUES ('$row[RaceID]','9')";variables ahve to be wrapped with ' either sideRegardsLiam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.