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 Link to comment https://forums.phpfreaks.com/topic/217468-cant-figure-out-error-column-doesnt-match/ 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.) Link to comment https://forums.phpfreaks.com/topic/217468-cant-figure-out-error-column-doesnt-match/#findComment-1129039 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() ? Link to comment https://forums.phpfreaks.com/topic/217468-cant-figure-out-error-column-doesnt-match/#findComment-1129061 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? Link to comment https://forums.phpfreaks.com/topic/217468-cant-figure-out-error-column-doesnt-match/#findComment-1129068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.