Deiviux Posted November 1, 2010 Share Posted November 1, 2010 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 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 1, 2010 Share Posted November 1, 2010 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.) Quote Link to comment Share on other sites More sharing options...
Deiviux Posted November 1, 2010 Author Share Posted November 1, 2010 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() ? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 1, 2010 Share Posted November 1, 2010 If you are using mysql, you should use mysql_real_escape_string. Does your database class have a method to escape data that is specific to the type of database being used? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.