SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: :( make it work

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got pretty simple query here

    mysql_query("UPDATE list (writeup,email) VALUES ('$writeup','$email')");

    put it just dosent want to work, writeup and email are passed through via a form( I made sure they were being passed through ) I also double-checked that those were valid fields in my database. I also mad sure that it is infact connected to the database..and it was....

    free for suggestions

    thanx
    later

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you checking for errors? I'm not all that familiar with mysql's special syntaxes (I use PostgreSQL now) but your SQL UPDATE syntax seems incorrect.

    http://www.compapp.dcu.ie/databases/f288.html has the correct syntax.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im pretty sure there are numerous ways of doing it. I have used this method since I begun doin MYSQL, and I have never had any trouble like this before

    However, it does seem to be missing the where part.. seen as how Im updating, i guess that would be pretty important

  4. #4
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't you need a WHERE statement? Otherwise the whole table will be updated.

    A couple of things you can try:

    Try restating your update query using SET

    mysql_query("UPDATE list SET
    writeup='$writeup',
    email='$email'");

    Try doing echo stements for $writeup & $email before you do your query statement to see values are being pass by the form.

    Best of Luck

  5. #5
    SitePoint Zealot Alarion's Avatar
    Join Date
    May 2001
    Location
    Virginia
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Update syntax should be:
    PHP Code:
    mysql_query("UPDATE list set writeup = '$writeup, email='$email'"); 
    Only insert cluases use the syntax you were attempting. If you are trying to insert a record then use:
    PHP Code:
    mysql_query("INSERT INTO list (writeup,email) VALUES ('$writeup','$email')"); 
    And CyberFuture is right, you need to tack a where clause on the end of that update statement or you will update every record in your table, which I am sure is NOT what you want
    -=Alarion=-
    Protollix - Linux hosting from $3.95/m


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
  •