Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy You have an error in your SQL syntax; check the manual that corresponds to your MySQL

    could someone please help me solve the following code error thanks

    PHP Code:
    <?php 
    //create_cat.php 
    include 'mysql.php'
    include 
    'header.php'

    if(
    $_SERVER['REQUEST_METHOD'] != 'POST'

        
    //someone is calling the file directly, which we don't want 
        
    echo 'This file cannot be called directly.'

    else 

        
    //check for sign in status 
        
    if(!$_SESSION['loggedIn']) 
        { 
            echo 
    'You must be signed in to post a reply.'mysql_error(); 
        } 
        else 
        { 
            
    //a real user posted a real reply 
             
    $topicid mysql_insert_id();  
            
    $sql "INSERT INTO  
                                post(content,  
                                      date,  
                                      topic,  
                                      postby) 
                      VALUES  
                                ('" 
    mysql_real_escape_string($_POST['content']) . "',  
                                     NOW(), 
                                      " 
    $topicid ", 
                            " 
    mysql_real_escape_string($_GET['id']) . ", 
                            " 
    $_SESSION['user_id'] . ")"
            
    $result mysql_query($sql); 
                             
            if(!
    $result
            { 
                echo 
    'Your reply has not been saved, please try again later.'mysql_error(); 
            } 
            else 
            { 
                echo 
    'Your reply has been saved, check out <a href="topic.php?id=' htmlentities($_GET['id']) . '">the topic</a>.'
            } 
        } 


    include 
    'footer.php'
    ?>

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    407
    Thanks
    18
    Thanked 26 Times in 26 Posts
    You're inserting 4 values into 3 keys, you need to either add the missing key or remove the extra value.
    Last edited by Dubz; 04-18-2013 at 02:29 AM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •