SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL error 1064

    I am getting this generic syntax error trying to run the following code:
    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 'SET `question` = 'asf', SET `asker` = '', SET `askeradd
    Code:
    switch ($process)	{
    	case "new":
    	$query = "INSERT INTO `" . $type . "s` 
    	 SET `id` = '" . $id . "', 
    	 SET `title` = '" . $title . "',
    	 SET `question` = '" . $question . "',
    	 SET `asker` = '" . $asker . "',
    	 SET `askeradd` = '" . $askeradd . "',
    	 SET `response` = '" . $response . "',
    	 SET `abstract` = '" . $abstract . "', 
    	 SET `author` = '1', 
    	 SET `status` = 'inactive'";
    	 
    	case "edit":
    	$query = "UPDATE `" . $type . "s` 
    	 SET `title` = '" . $title . "', 
    	 SET `question` = '" . $question . "', 
    	 SET `asker` = '" . $asker . "', 
    	 SET `askeradd` = '" . $askeradd . "', 
    	 SET `response` = '" . $response . "', 
    	 SET `abstract` = '" . $abstract . "', 
    	 SET `date` = '" . $date . "', 
    	 SET `status` = '" . $status . "', 
    	 SET `author` = '" . $author . "', 
    	 WHERE `id` = '" . $id . "'";	
    }	
    		  
    mysql_query ($query) or die (mysql_error() . "<br><br>" . mysql_errno());
    I haven't been able to find any reason for this searching or going over the code repeatedly. Suggestions?
    <<< johnny chidiac
    johnnydaboy@mac.com

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    you're only allowed one SET per statement

    in any case, you might want to use the standard version of the INSERT syntax --
    Code:
    insert into  $type 
    ( id,title,question,asker,askeradd
    ,response,abstract,author,status)
    values
    ( $id,'$title','$question','$asker','$askeradd'
    ,'$response','$abstract',1,'inactive')
    and in the update statement, just use the one SET keyword with commas for the other values --
    Code:
    UPDATE $type
       SET title = '$title'
         , question = '$question'
         , asker = '$asker'
         , askeradd = '$askeradd'
         , response = '$response'
         , abstract = '$abstract'
         , date = '$date'
         , status = '$status'
         , author = '$author', 
     WHERE id = $id
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! Obviously I'm new at this. That's just one of those things that I never thought to look at.


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
  •