Jump to content

error in my sql coding


Go to solution Solved by trq,

Recommended Posts

i keep having a error with my code saying the following Error. Please try again laterColumn count doesn't match value count at row 1 
could someone help me solve this :)

 

<?php  
include 'header.php';
include 'mysql.php';  
echo '<h3>Create Catergory</h3>';
if($_SERVER['REQUEST_METHOD'] != 'POST')  
{  
    //the form hasn't been posted yet, display it  
    echo '<form method="post" action="">  
           Catergory Name: <input type="text" name="name" /></p>  
           Catergory Description: <input type="textarea" name="description"></p>   
            <input type="submit" value="Add Catergory" />  
         </form>'; 
} 
else 
{ 
    //the form has been posted, so save it 
	 $sql = "INSERT INTO 
                    catagories(name, description) 
                VALUES('" . mysql_real_escape_string($_POST['name']) . "', 				
                       '" . mysql_real_escape_string($_POST['description']) . "', 
                        NOW(),   0)";  
        $result = mysql_query($sql);  
        if(!$result)  
        {  
            echo 'Error. Please try again later';//. mysql_error(); 
			exit();
        } 
        else 
        { 
            echo 'New category successfully added.'; 
			exit();
        } 
} 
include 'footer.php';
?>  

 

 

Link to comment
https://forums.phpfreaks.com/topic/275745-error-in-my-sql-coding/
Share on other sites

  • Solution

The error is pretty straight forward. You are trying to insert 4 values into 2 columns.

 

darkfreaks: If you can answer the question at hand please do, otherwise, leave the thread to people who can. We really don't need every thread around here having you highlight deprecations. Like your security scanning replies, it's going to get pretty old pretty quick.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.