Error when trying to UPDATE

Discussion in 'MySQL' started by teamshop, Feb 11, 2006.

  1. #1
    I am getting the following error when trying to run an UPDATE query:
    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 'read='http://www

    The code I am using to UPDATE the query is:
    
    $pid = $HTTP_POST_VARS["pid"];  
    $company = $HTTP_POST_VARS["company"];
    $title = $HTTP_POST_VARS["title"];
    $version = $HTTP_POST_VARS["version"];
    $pdate = $HTTP_POST_VARS["pdate"];  
    $website = $HTTP_POST_VARS["website"];
    $email = $HTTP_POST_VARS["email"];
    $cost = $HTTP_POST_VARS["cost"];
    $ptype = $HTTP_POST_VARS["ptype"];
    $os = $HTTP_POST_VARS["os"];
    $ksize = $HTTP_POST_VARS["ksize"];
    $maincategory = $HTTP_POST_VARS["main"];
    $subcategory = $HTTP_POST_VARS["subcat"];
    $requirements = $HTTP_POST_VARS["requirements"];
    $keywords = $HTTP_POST_VARS["keywords"];
    $shortdescription = $HTTP_POST_VARS["shortdescription"];
    $longdescription = $HTTP_POST_VARS["longdescription"];
    $limits = $HTTP_POST_VARS["limits"];
    $homepage = $HTTP_POST_VARS["homepage"];
    $icon = $HTTP_POST_VARS["icon"];
    $screenshot = $HTTP_POST_VARS["screenshot"];
    $reviewed = $HTTP_POST_VARS["reviewed"];
    $ourrating = $HTTP_POST_VARS["ourrating"];
    $read = $HTTP_POST_VARS["read"];
    $padfile = $HTTP_POST_VARS["padfile"];
    $download = $HTTP_POST_VARS["download"];
    $featured = $HTTP_POST_VARS["featured"];
    $mainfeatured = $HTTP_POST_VARS["mainfeatured"];
    $catfeatured = $HTTP_POST_VARS["catfeatured"];
    $subfeatured = $HTTP_POST_VARS["subfeatured"];
     
    $link_id = mysql_connect("localhost",$userid,$userpassword) or die ("Error connecting to the database server.");
      mysql_select_db ($dbname);
    if (!mysql_query("UPDATE programs SET id='$pid', company='$company', title='$title', version='$version', pdate='$pdate', website='$website', email='$email', cost='$cost', ptype='$ptype', os='$os', ksize='$ksize', maincategory='$maincategory', subcategory='$subcategory', requirements='$requirements', shortdescription='$shortdescription', longdescription='$longdescription', limits='$limits', homepage='$homepage', icon='$icon', screenshot='$screenshot', padfile='$padfile', download='$download', reviewed='$reviewed', ourrating='$ourrating', read='$read', featured='$featured', mainfeatured='$mainfeatured', catfeatured='$catfeatured', subfeatured='$subfeatured'  WHERE id = '$pid'", $link_id)) die(mysql_error());
    PHP:
    The variable is being passed properly from the $HTTP_POST_VARS["read"]; and the table field name and type should be correct. If I remove the read='$read' from the UPDATE script it works properly and updates all other fields. Any ideas why it doesn't like this?
     
    teamshop, Feb 11, 2006 IP
  2. Ian

    Ian Well-Known Member

    Messages:
    409
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    125
    #2
    Are there any odd characters in that value? Any quotations or apostrophes? Post the URL of what you're trying to insert for that value and hopefully we can see from that if there's an issue.

    Ian

     
    Ian, Feb 11, 2006 IP
  3. teamshop

    teamshop Plainsman

    Messages:
    345
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No, the value contains a URL and still gives the error if the value is null
     
    teamshop, Feb 11, 2006 IP
  4. Ian

    Ian Well-Known Member

    Messages:
    409
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    125
    #4
    That's odd. What's the URL for that variable? PM me if you don't want to post it.

    Ian
     
    Ian, Feb 11, 2006 IP
  5. teamshop

    teamshop Plainsman

    Messages:
    345
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #5
    teamshop, Feb 11, 2006 IP
  6. teamshop

    teamshop Plainsman

    Messages:
    345
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Nevermind, got it working.
     
    teamshop, Feb 12, 2006 IP