SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error updating a file

    PHP Code:
    $update_query mysql_query("UPDATE sns SET 
    assign_to='"
    .$assign_to."', aa_comments='".$aa_comments."' 
    WHERE ID = '"
    .$ticket_sns."'") or die (mysql_error()); 
    Does anyone see anything wrong with this? I compared this to another update query I am running and it runs perfectly, but this one does not. Here is the error it outputs.

    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 's find out.
    ' WHERE ID = '11'' at line 1

    I echoed the variables, and they are all correct. I can find no problem with this, please help.

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you just single quote the variables like below:

    PHP Code:

    $update_query 
    mysql_query("UPDATE sns SET
    assign_to='
    $assign_to', aa_comments='$aa_comments'
    WHERE ID = '
    $ticket_sns'") or die (mysql_error()); 
    HTH

    Mark.

  3. #3
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it that way as well, same error. I verified the fields were spelled right as well as the db name. I used strip slashes, same thing. I really am at a loss as to why it's not working.

  4. #4
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand the error correctly it's this part WHERE ID = '11'' for some reason it is no seeing the second apostrophe before the quotes. Is that right? If that's the case why isn't it seeing it?

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $update_query mysql_query("UPDATE sns 
                                 SET assign_to="
    $assign_to ."
                                 AND aa_comments="
    $aa_comments ."
                                 WHERE ID ="
    $ticket_sns) or die (mysql_error()); 
    cheers

  6. #6
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I use yours I get 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 '
    Comments added by leribes
    Date added 10/08/2


    The comments to the date area is part of the aa_comments variable.

  7. #7
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me as you this, the comments area is being set up like so
    PHP Code:
    $prev_aa_comments $ticket_array['aa_comments'];
    $aa_comments "&nbsp;<br /> $aa_comments <br /> $prev_aa_comments"
    Could it be the type of data I am entering?

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $update_query mysql_query("UPDATE sns 
                                 SET assign_to = '
    $assign_to
                                 AND aa_comments = '
    $aa_comments'
                                 WHERE ID = '
    $ticket_sns'") or die (mysql_error()); 
    this should work!!!

  9. #9
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out. I was stringing together several variables and something with the way I was putting them together threw off the sql. I changed how I was combining them and it worked.

  10. #10
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how was it exaclty that you combined them in the end, as in reminders example or a different way!?

  11. #11
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It ended up using something like this $new_comment = "$old_comment <br /> $current_comment";

    Initially I didn't understand I could put the variable right there. I had it "<br /> $old_comment <br /> $current_comment";

    If I had a space or a <br /> right after the " then it wouldn't read it for some reason.


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
  •