SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi everyone. I have a simple question about using the command UPDATE. I wrote a simple script that displayed the values of one of the rows of a column in seperate text boxes of a form. That part works. Now I edit the text in the textboxes and submit the form where it posts to a new script that is supposed to use the update command to update the data. However, it never works. I use this to do it:
    $query = "UPDATE INTO coasters SET coastername='$coastername',length='$length',WHERE coasterid='$coasterid'";

    $result = "mysql_db_query($db, $query, $connect)";

    This never updates the database. How do I get this to work?
    --Matt
    http://www.6flagsohio.com

  2. #2
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    There are two errors in your query:
    You cant use UPDATE INTO, its just UPDATE
    You have an extra comma after $length

    This query should work:
    $query = "UPDATE coasters SET coastername='$coastername',length='$length' WHERE coasterid='$coasterid'";

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow isuru posted at the exact same time as me.

    should just be

    $query = "UPDATE coasters SET coastername='$coastername',length='$length' WHERE coasterid='$coasterid'";

    $result = mysql_query($query, $connect);


    Note the absence of INTO and the comma after '$length'

    Also the quote have been removed from the mysql_query line since it is a function also the $connect var is optional and can be done like

    $result = mysql_query($query);




    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, your help is greatly appreciated.
    --Matt
    http://www.6flagsohio.com


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
  •