php - PDO Update not working -
im trying pdo update mysql database. not showing errors, neither updating table.
here code im using. user selects post value drop down list.
if (isset($_post['changelearningstyle'])){ if (isset($_post['learning'])){ $var6 = $_post['learning']; $stmt8 = $db->prepare("update users set learningstyle = $var6 username = ? , learningstyle = ?"); $stmt8->execute(array($id, $learningstyle)); $alert = '<div id="title1">your learning style have been updated</div>'; } } /**and html looks this: **/ <form name="changestyle" method="post"> <div id="resetlearningstyle"> <div id="tab6"> <h4 id="black">learning style</h4> <h5>current style: <?php echo($learningstyle) ?></h5> <select id="learning" name="learning" class="span3"> <option value="">select style</option> <option value="auditory">auditory</option> <option value="visual">visual</option> <option value="persuasive">persuasive</option> <option value="active">active</option> </select> </div> <input class="btn btn-inverse" type="submit" name="changelearningstyle" value="reset learning style"> </form> /**table structure **/
-- table structure table users
create table `users` ( `id` int(20) not null auto_increment, `fname` varchar(200) not null, `lname` varchar(200) not null, `username` varchar(200) not null, `password` varchar(200) not null, `country` varchar(200) not null, `rootlanugage` varchar(200) not null, `learningstyle` varchar(200) not null, `language` varchar(200) not null, `icon` varchar(200) not null, primary key (`id`) ) engine=myisam default charset=utf8 auto_increment=31 ;
thank in advance!
to make show errors, add line of code right after connecting db:
$db->setattribute(pdo::attr_errmode, pdo::errmode_exception);
Comments
Post a Comment