{MYSQL+php} wont insert error

Discussion in 'PHP' started by fi3h3r, Aug 12, 2010.

  1. #1
    This is the thing i need to work
    
    $sql="INSERT INTO forum_categorys(catname, desc, ffname)
    VALUES
    ('$categorys', '$descc', '$categorys')"; 
    $result=mysql_query($sql);
    
    Code (markup):
    But this one works
    
    $sql="INSERT INTO forum_categorys(catname, ffname)
    VALUES
    ('$categorys', '$categorys')"; 
    $result=mysql_query($sql);
    
    Code (markup):

    Any help rep+
     
    fi3h3r, Aug 12, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Execute this code and write here what error it shows:

    
    $sql="INSERT INTO forum_categorys(catname, desc, ffname)
    VALUES
    ('$categorys', '$descc', '$categorys')"; 
    $result=mysql_query($sql) or die(mysql_error);
    
    PHP:
     
    s_ruben, Aug 12, 2010 IP
  3. fi3h3r

    fi3h3r Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it prints
    
    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 'desc, ffname) VALUES ('yes', 'yes', 'yes')' at line 1
    
    Code (markup):
    BTW its mysql_error()
     
    fi3h3r, Aug 12, 2010 IP
  4. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #4
    Can you write here "forum_categorys" table structure? And write here what the variable $sql prints ( echo($sql); :) ).
     
    s_ruben, Aug 12, 2010 IP
  5. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #5
    Or try this:

    
    $sql="INSERT INTO forum_categorys (`catname`, `desc`, `ffname`)
    VALUES
    ('$categorys', '$descc', '$categorys')";
    $result=mysql_query($sql) or die(mysql_error);
    
    PHP:
     
    s_ruben, Aug 12, 2010 IP
  6. hiuf1

    hiuf1 Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    your table structure is not correct that's why that is giving error
     
    hiuf1, Aug 12, 2010 IP