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 :)

 

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.)

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()

?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.