Jump to content

error in mysql


lional

Recommended Posts

Hi All

I have been battling with an insert query, but only on one table. Here is my error message followed by the code snippet

Failed1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select, select_day, select_month, select_year, sem, sem_day, sem_month, sem_year' at line 1

$query_deg_in = "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, masterlodge)VALUES('$member_no_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_in = mysql_query ($query_deg_in);

 

Thanks

 

Lional

Link to comment
Share on other sites

how it is allowed while creating the table.

 

Perhaps because of the way you create your tables.  There's nothing to stop you using reserved words - unless working code is one of your objectives.

 

The sloppy workaround is `backticks`

Link to comment
Share on other sites

$query_deg_in = "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, masterlodge)VALUES('$member_no_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_in = mysql_query ($query_deg_in);

 

Use like this:

$query_deg_in = "INSERT INTO cc_degrees (`member_no`, `royal`, `royal_day`, `royal_month`, `royal_year`, `select`, `select_day`,...)VALUES('$member_no_out','$com_royal_out','$royal_day_out','$royal_month_out','$royal_year_...)";

Link to comment
Share on other sites

Use like this:

$query_deg_in = "INSERT INTO cc_degrees (`member_no`, `royal`, `royal_day`, `royal_month`, `royal_year`, `select`, `select_day`,...)VALUES('$member_no_out','$com_royal_out','$royal_day_out','$royal_month_out','$royal_year_...)";

 

NO... don't -- change the column name.

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.