lional Posted July 3, 2007 Share Posted July 3, 2007 Hi All I am having a very frustrating morning. I am trying to either insert insert data into a mysql table based on a condition. there are no records in the table currently, so the insert should be used. I have tested all the variables and they are pulling the correct values. What is frustrating is that my application has three legs to it which are identical in structure but the tables and variables changes. The insert works perfectly on those scripts. Is there a way to insert an error script into php to see if the data does actually get written to the table, and if not what is the reason. I have included the code segment: $query_deg_cc_member = "SELECT * from cc_degrees WHERE member_no = '$cc_ass_mem_number_out'"; $result_deg_cc_member = mysql_query($query_deg_cc_member); $num_deg_cc_member = @mysql_num_rows($result_deg_cc_member); if ($num_deg_cc_member == 0) { $query_deg_member1 = "INSERT INTO cc_degrees (member_no, royal, royal_day, royal_month, royal_year, select, select_day, select_month, select_year, sem, sem_day, sem_month, sem_year, master_lodge) VALUES ('$cc_ass_mem_number_out', '$com_royal_out', '$royal_day_out', '$royal_month_out', '$royal_year_out', '$com_select_out', '$select_day_out', '$select_month_out', '$select_year_out', '$com_sem_out', '$sem_day_out', '$sem_month_out', '$sem_year_out', '$master_lodge_out')"; $result_deg_member1 = @mysql_query ($query_deg_member1); } if ($num_deg_member != 0) { print "Not Equal"; $query_deg_in = "UPDATE cc_degrees SET royal = '$com_royal_out', royal_day = '$royal_day_out', royal_month = '$royal_month_out', royal_year = '$royal_year_out', select = '$com_select_out', select_day = '$select_day_out', select_month = '$select_month_out', select_year = '$select_year_out', sem = '$com_sem_out', sem_day = '$sem_day_out', sem_month = '$sem_month_out', sem_year = '$sem_year_out', master_lodge = '$master_lodge_out' WHERE member_no = '$cc_ass_mem_number_out'"; $result_deg_in = @mysql_query ($query_deg_in); } Thanks Lional Quote Link to comment Share on other sites More sharing options...
jagat21 Posted July 3, 2007 Share Posted July 3, 2007 Try this code.... <?php $query_deg_cc_member = "SELECT * from cc_degrees WHERE member_no = '$cc_ass_mem_number_out'"; $result_deg_cc_member = mysql_query($query_deg_cc_member); $num_deg_cc_member = @mysql_num_rows($result_deg_cc_member); if ($num_deg_cc_member == 0) { $query_deg_member1 = "INSERT INTO cc_degrees (member_no, royal, royal_day, royal_month, royal_year, select, select_day, select_month, select_year, sem, sem_day, sem_month, sem_year, master_lodge) VALUES ('$cc_ass_mem_number_out', '$com_royal_out', '$royal_day_out', '$royal_month_out', '$royal_year_out', '$com_select_out', '$select_day_out', '$select_month_out', '$select_year_out', '$com_sem_out', '$sem_day_out', '$sem_month_out', '$sem_year_out', '$master_lodge_out')"; $result_deg_member1 = @mysql_query ($query_deg_member1); } if ($num_deg_cc_member != 0) { print "Not Equal"; $query_deg_in = "UPDATE cc_degrees SET royal = '$com_royal_out', royal_day = '$royal_day_out', royal_month = '$royal_month_out', royal_year = '$royal_year_out', select = '$com_select_out', select_day = '$select_day_out', select_month = '$select_month_out', select_year = '$select_year_out', sem = '$com_sem_out', sem_day = '$sem_day_out', sem_month = '$sem_month_out', sem_year = '$sem_year_out', master_lodge = '$master_lodge_out' WHERE member_no = '$cc_ass_mem_number_out'"; $result_deg_in = @mysql_query ($query_deg_in); } ?> Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 3, 2007 Share Posted July 3, 2007 First I'd remove all trace of every @ symbol before any MySQL functions. Why try and hide any possible error messages when you're trying to debug? Quote Link to comment Share on other sites More sharing options...
lional Posted July 3, 2007 Author Share Posted July 3, 2007 I have tried the code from jagat21, from what I can see the only change is the <?php tags. If this is the case, then what I gave you is only a code segment, and I have the <?php tags. I also removed the @ symboils but I get no error message Thanks Lional 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.