mcmuney Posted January 4, 2014 Share Posted January 4, 2014 I'm using the code below to insert data into my DB, but it's executing twice. Not as a duplicate, but with it's own unique line. How can I fix this? if($ft>0) { $ft="UPDATE sc_member SET mem_feature_flag='1' WHERE scm_mem_id='$ft'"; $res=$db->update($ft); // SEND MESSAGE $time=time(); $ft=$_GET['ft']; $txt_sb_body="Hey ".$fname.", You have been featured! Keep up your activity! {automated message}"; $sql="INSERT INTO sc_messages (`smg_from`, `smg_to`, `smg_subject`, `smg_body`, `smg_sent_del`, `smg_postdate`, `scm_bulletin`, `send_cron`) VALUES ('1','$ft','Featured Alert','$txt_sb_body','1','$time', '6', 'N')"; $result = mysql_query($sql); } Quote Link to comment https://forums.phpfreaks.com/topic/285077-insert-code-writing-in-my-db-twice/ Share on other sites More sharing options...
Rifts Posted January 4, 2014 Share Posted January 4, 2014 post more code Quote Link to comment https://forums.phpfreaks.com/topic/285077-insert-code-writing-in-my-db-twice/#findComment-1463794 Share on other sites More sharing options...
mcmuney Posted January 4, 2014 Author Share Posted January 4, 2014 That's all the code. This executes when the page has.. example.php?ft=1 (anytime ft>0). It's the insert portion that's executing twice. Quote Link to comment https://forums.phpfreaks.com/topic/285077-insert-code-writing-in-my-db-twice/#findComment-1463799 Share on other sites More sharing options...
jazzman1 Posted January 4, 2014 Share Posted January 4, 2014 What happens if you try to comment the $result variable? $sql="INSERT INTO sc_messages (`smg_from`, `smg_to`, `smg_subject`, `smg_body`, `smg_sent_del`, `smg_postdate`, `scm_bulletin`, `send_cron`) VALUES ('1','$ft','Featured Alert','$txt_sb_body','1','$time', '6', 'N')"; //$result = mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/285077-insert-code-writing-in-my-db-twice/#findComment-1463820 Share on other sites More sharing options...
Barand Posted January 4, 2014 Share Posted January 4, 2014 If you are going to do that it would make more sense to echo the $sql so you can see if it is being called twice. Quote Link to comment https://forums.phpfreaks.com/topic/285077-insert-code-writing-in-my-db-twice/#findComment-1463837 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.