Jump to content

Can't figure out error (Column doesnt match)


Deiviux

Recommended Posts

Hello, i am writing my own CMS, and now i got stuck. I am still getting error:

 

Column count doesn't match value count at row 1

 

That's the code.

 

if(isset($_POST['vardas']) && isset($_POST['pastas']) && isset($_POST['tekstas'])) {
   $admin = "0"; $url = "";
   $vardas = htmlspecialchars($_POST['vardas']);
   $pastas = htmlspecialchars($_POST['pastas']);
   if (tikrinam_url(htmlspecialchars($_POST['url']))) {
         $url = htmlspecialchars($_POST['url']);
   }
   $tekstas = htmlspecialchars($_POST['tekstas']);
   $naujienos_id = htmlspecialchars($_GET['id']);
   $ip = $_SERVER["REMOTE_ADDR"];
   $laikas = date("Y/m/j");
   $slaptazodis = $_POST['slaptazodis'];
   if(isset($slaptazodis) && $slaptazodis = "anarchija") 
   {
   $admin = "1";
   }
   $komentaru_idejimas = dbquery("INSERT INTO komentarai  (nid, vardas, tekstas, ip, url, pastas, laikas, admin) VALUES ('$naujienos_id', '$vardas', '$tekstas', '$ip', '$url' '$pastas', '$laikas', '$admin')");
}

 

Thanks :)

 

Link to comment
Share on other sites

I recommend forming your query in a variable, such as $query, so that you can echo it to see what it actually contains.

 

You should also be escaping the data values being put into the query (you likely have some data with single-quotes and commas that are causing the error.)

Link to comment
Share on other sites

I recommend forming your query in a variable, such as $query, so that you can echo it to see what it actually contains.

 

You should also be escaping the data values being put into the query (you likely have some data with single-quotes and commas that are causing the error.)

 

So I should use function

addslashes()

?

 

Link to comment
Share on other sites

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.