SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Gonna mad due to Update problem plzz help urgent

    I wrote following query;

    PHP Code:
    $Query "UPDATE customer SET firstname = " $formVars["first_Name"] .
                 
    "WHERE cust_id = " $customerID
    But following error is being occured;

    Error 1064 : 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 'cust_id = 1' at line 1

    Actually it should update the record whose id is
    PHP Code:
    $customerID 
    which is '1' in this case, in the field
    PHP Code:
    firstname 
    with the data in
    PHP Code:
    $formVars["first_Name"
    .

    plzz help me.........
    [COLOR=SlateGray]
    Web Developer @ VeriQual

  2. #2
    SitePoint Addict
    Join Date
    Jan 2004
    Location
    New York
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put a space right before the WHERE in the quotes.

  3. #3
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I put the space but Now the error is

    Error 1054 : Unknown column 'Mohsin' in 'field list'

    Mohsin is the actual content which was to be updated.

    Waiting for reply...............>>>>>>>>>>
    [COLOR=SlateGray]
    Web Developer @ VeriQual

  4. #4
    SitePoint Member bhinard's Avatar
    Join Date
    Jan 2005
    Location
    Caen
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this
    PHP Code:
     $Query "UPDATE customer SET firstname = " $formVars["first_Name"] .
                 
    "WHERE cust_id = '{$customerID}'; 

  5. #5
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No will need to put a " before ;

    but it is showing the very first one error. :'(
    [COLOR=SlateGray]
    Web Developer @ VeriQual

  6. #6
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    solution

    Here is the solution for your problem

    $query=("update customer set firstname='$formVars[first_Name]' WHERE cust_id='$customerID' ");

    This code will work definately.
    Regards
    Ramneek Chadha
    Xaprio Solutions

  7. #7
    SitePoint Enthusiast zfade3's Avatar
    Join Date
    Jul 2005
    Location
    Endor
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MohsinAli
    I put the space but Now the error is

    Error 1054 : Unknown column 'Mohsin' in 'field list'

    Mohsin is the actual content which was to be updated.

    Waiting for reply...............>>>>>>>>>> :rolleyes:
    This error almost always comes because there are no 'single quotes' around the value that your are trying to campare with. Sometimes MySQL will guess correctly and match the column with the value, but other times it will give an unknown column error. It is always best to but the single quotes around the values as Ramneek has done.

    Jimmy Z


Bookmarks

Posting Permissions

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