use of reserved words in MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shalini Bhalla
    New Member
    • Dec 2007
    • 190

    #1

    use of reserved words in MySQL

    i am getting SQL syntax mistake in PHP can you tell me why ?

    my code is [PHP]echo $sql = "insert into cont_event(cont _code , event_name, date, subject, remarks, repeat) values('$cont', '$eve_name', CURDATE(), '$sub', '$msg', '$repeat')";[/PHP] and error i m getting is

    Error: 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 'repeat) values('17' ,'gjhgjhg' , CURDATE(), 'fgdgfdg', 'fdgfdfdg
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by Shalini Bhalla
    i am getting SQL syntax mistake in PHP can you tell me why ?


    my code is

    [PHP]echo $sql = "insert into cont_event(cont _code , event_name, date, subject, remarks, repeat) values('$cont', '$eve_name', CURDATE(), '$sub', '$msg', '$repeat')";[/PHP]



    and error i m getting is


    Error: 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 'repeat) values('17' ,'gjhgjhg' , CURDATE(), 'fgdgfdg', 'fdgfdfdg
    Try printing $sql on the screen and check if the query that is formed is of perfect syntax.

    Could you please post the output of $sql after the values being substituted for all the variables for reference.

    Comment

    • Shalini Bhalla
      New Member
      • Dec 2007
      • 190

      #3
      Thanks alot , but i have found it i used 'repeat' as a field name which is a key word ao , i have corrected it and now it is working

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Yes: repeat is one of a number of reserved words in MySQL. A list (version 5) can be found in chapter Reserved words in the MySQL documentation.

        Please use a more meaningful title next time you open a thread.
        You cannot call "Pls Tell My mistake I'm stucked ..." a really 'say-it-all' title that attracts many members to have a look.

        Ronald

        Comment

        Working...