php - I have an error in mySQL -
fatal error: uncaught exception 'pdoexception' message 'sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1' in /home//domains//public_html/new/.php:140 stack trace: #0 /home//domains//public_html/new/.php(140): pdostatement->execute() #1 {main} thrown in /home//domains//public_html/new/***.php on line 140
below find code:
if(count($errors) == 0) { $title = trim($_post['title']); $category = trim($_post['category']); $ing = trim($_post['ing']); $ing_pond = trim($_post['ing_pond']); $ing_note = trim($_post['ing_note']); $description = trim($_post['description']); $time = trim($_post['time']); $insert = $dbh->prepare('insert recettes (id, id_user, title, category, ing, ing_pond, ing_note, description, graad, time) values (null, :meid :title, :category, :ing, :ing_pond, :ing_note, :description, :graad, :time'); $insert->bindparam(':meid', $me['id'], pdo::param_int); $insert->bindparam(':title', $title, pdo::param_str); $insert->bindparam(':category', $category, pdo::param_str); $insert->bindparam(':ing', $ing, pdo::param_str); $insert->bindparam(':ing_pond', $ing_pond, pdo::param_str); $insert->bindparam(':ing_note', $ing_note, pdo::param_str); $insert->bindparam(':description', $description, pdo::param_str); $insert->bindparam(':graad', $graad, pdo::param_str); $insert->bindparam(':time', $time, pdo::param_str); $insert->execute(); $uid = $dbh->lastinsertid(); echo alert('uw gerecht succesvol toegevoegd.', 'success'); $added = true; }else{ echo alert('er ging wat mis. de volgende dingen gingen fout:<ul><li>' . join('</li><li>', $errors) . '</li></ul>het gerecht helaas niet toegevoegd.', 'danger'); } how solved, can please me :-)
thnx lot!
replace line:
$insert = $dbh->prepare('insert recettes (id, id_user, title, category, ing, ing_pond, ing_note, description, graad, time) values (null, :meid :title, :category, :ing, :ing_pond, :ing_note, :description, :graad, :time'); with line:
$insert = $dbh->prepare('insert recettes (id, id_user, title, category, ing, ing_pond, ing_note, description, graad, time) values (null, :meid, :title, :category, :ing, :ing_pond, :ing_note, :description, :graad, :time)'); you forget last ) in code , comma , between :meid , :title
Comments
Post a Comment