garethhall Posted June 14, 2008 Share Posted June 14, 2008 Hi guys I have an insert into query for my DB but for some reason when it runs it enters the values twice for $addTradeAndTechnicalName $addTradeAndTechnicalEmailAddress so I get a duplicate in my table Can anyone tell me why? Look at the last if statement Thanks Guys G <?php if($_GET[pageName] == "currentJobs"){ do { $radioBtnName = $_POST[TradeAndTechnical.$row_TradeAndTechnical[id]]; $sendTo = $_POST[sendTo.TradeAndTechnical.$row_TradeAndTechnical[id]]; $query_TradeAndTechnical_alter = "update `Trade and Technical` set active='$radioBtnName', emailTo='$sendTo' WHERE id = '$row_TradeAndTechnical[id]'"; $result_TradeAndTechnical_alter = mysql_query($query_TradeAndTechnical_alter); mysql_query($query_TradeAndTechnical_alter); } while ($row_TradeAndTechnical = mysql_fetch_assoc($TradeAndTechnical)); do { $radioBtnName = $_POST[Engineering.$row_Engineering[id]]; $query_Engineering_alter = "update `Engineering` set active='$radioBtnName' WHERE id = '$row_Engineering[id]'"; $result_Engineering_alter = mysql_query($query_Engineering_alter); mysql_query($query_Engineering_alter); } while ($row_Engineering = mysql_fetch_assoc($Engineering)); do { $radioBtnName = $_POST[surveying.$row_Surveying[id]]; $query_Surveying_alter = "update `Surveying` set active='$radioBtnName' WHERE id = '$row_Surveying[id]'"; $result_Surveying_alter = mysql_query($query_Surveying_alter); mysql_query($query_Surveying_alter); } while ($row_Surveying = mysql_fetch_assoc($Surveying)); do { $radioBtnName = $_POST[Construction.$row_Construction[id]]; $query_Construction_alter = "update `Construction` set active='$radioBtnName' WHERE id = '$row_Construction[id]'"; $result_Construction_alter = mysql_query($query_Construction_alter); mysql_query($query_Construction_alter); } while ($row_Construction = mysql_fetch_assoc($Construction)); do { $radioBtnName = $_POST[Aviation.$row_Aviation[id]]; $query_Aviation_alter = "update `Aviation` set active='$radioBtnName' WHERE id = '$row_Aviation[id]'"; $result_Aviation_alter = mysql_query($query_Aviation_alter); mysql_query($query_Aviation_alter); } while ($row_Aviation = mysql_fetch_assoc($Aviation)); do { $radioBtnName = $_POST[HealthAndMedical.$row_HealthAndMedical[id]]; $query_HealthAndMedical_alter = "update `Health and Medical` set active='$radioBtnName' WHERE id = '$row_HealthAndMedical[id]'"; $result_HealthAndMedical_alter = mysql_query($query_HealthAndMedical_alter); mysql_query($query_EngineeringHealthAndMedical_alter); } while ($row_HealthAndMedical = mysql_fetch_assoc($HealthAndMedical)); if($_POST[addTradeAndTechnicalName] <>""){ $query_TradeAndTechnical_add = "insert into `Trade and Technical` (`id`,`jobName`,`active`,`emailTo`) values (Null, '$_POST[addTradeAndTechnicalName]', 'Yes', '$_POST[addTradeAndTechnicalEmailAddress]')"; $result_TradeAndTechnical_add = mysql_query($query_TradeAndTechnical_add); mysql_query($query_TradeAndTechnical_add); }; }; ?> Quote Link to comment Share on other sites More sharing options...
ThunderAI Posted June 14, 2008 Share Posted June 14, 2008 I dont know if I have an awer to your question, but something i noticed. I would stay away from tables, stored procedures, and the like with spaces in them. I always name my tables tbl_x, and my other stuff with appropriate header. The oher thing i noticed is that the syntax you are using for your sql is not breaking the text to allow for the form variable. I understand how your doing it works, but i dont find it easy to read. That and your last two lines look to be causing the problem to me.. Why do you need both lines there. What happends if you leave out "$result_TradeAndTechnical_add = mysql_query($query_TradeAndTechnical_add);" Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 14, 2008 Share Posted June 14, 2008 Take out the 3rd to last line (I think) with just mysql_query($somelongvarname) on it. 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.