www.webdeveloper.com
Results 1 to 4 of 4

Thread: Invalid field name

  1. #1
    Join Date
    Mar 2006
    Posts
    413

    Invalid field name

    Hi:

    I have a field name:

    Tea/Coffee.

    I have a simple query to change it based on its state (0 or 1).

    my query is run by php, but it won't change.

    I assume its because the character ("/") is illegal.

    How can i get round this problem.

    Thanks Guys

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    Don't use the / in your column name. Rename the column (you'll need to use a SQL client to do this, not PHP) to something like Tea_Coffee.

  3. #3
    Join Date
    Mar 2006
    Posts
    413
    Changing the field name is NOT an option, i did not set up the database and thousands of sites would need updating if i renamed this field.

    Sorry i should have stated that.

    What i need is a workaround, strangely when i'm reading in the data it displays correctly, anyone know why that is???

  4. #4
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    To be honest, there is no work around. You can try encapsulating the field name in back ticks, `Tea/Coffee` but in all honesty, that is an invalid column name. MySQL's partially to blame because it let whoever made the table make it with the character, but the DBA in question should have known better, in my opinion.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles