Jump to content

MYsql insert problem.


lional

Recommended Posts

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

Link to comment
Share on other sites

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);

}

 

?>

;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.