SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    May 2005
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Mysql Error With Update Query

    Friends, i have a query like this in my php script.....


    PHP Code:
    $query12="UPDATE attendance
              SET attend='
    $atten1',
                 grade='
    $gra',
                 comments='
    $comm',
                 username='
    $user',
              WHERE date='
    $day' AND class='$cla'  ";
    $result12=mysql_query($query12) or die(mysql_error()); 
    i get the following error:

    You have an error in your SQL syntax near 'WHERE date='06-08-2005' AND class='TYBCOM' ' at line 6

    wat is to be noted is that the query is not on line 6 in my php script.

    the db table is like this:
    Field Type Null Default
    attend text No
    grade varchar(32) No
    comments mediumtext No
    username varchar(64) No
    class varchar(32) No
    attendance_id int(11) No
    date varchar(64) No


    kindly help...wld b gr8ful...

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to remove the comma after username='$user'.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,262
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    another fine example which illustrates the superiority of using leading commas in formatted SQL

    see http://www.sitepoint.com/forums/show...13#post1654095
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •