mjahkoh Posted August 18, 2014 Share Posted August 18, 2014 the sql statement dont execute: what would be the problem? $sql = "UPDATE ".prefix("loanapplication")." SET firstname = :firstname, secondname = :secondname, surname = :surname, officialworkemail = :officialworkemail"; $sql.= " WHERE username=:username"; $sql.= " WHERE username=:username"; echo "$sql: $sql<br>"; //print_r($sql); $stmt = $database->connection->prepare($sql); $stmt->bindParam(':username',$session->username); $stmt->bindParam(':firstname',$firstname); $stmt->bindParam(':secondname',$secondname); $stmt->bindParam(':surname',$surname); $stmt->bindParam(':officialworkemail',$officialworkemail); $stmt->execute(); sql =UPDATE `emr_loanapplication` SET firstname = :firstname, secondname = :secondname, surname = :surname, officialworkemail = :officialworkemail WHERE username=:username Quote Link to comment https://forums.phpfreaks.com/topic/290509-pdo-update-statement-wont-execute/ Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2014 Share Posted August 18, 2014 (edited) To find why your query is failing you need to use $stmt->errorInfo() // if the prepared query failed, trigger an error if(!$stmt->execute()) { trigger_error('Update query failed: ' . $stmt->errorInfo(), E_USER_ERROR); } Edited August 18, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/290509-pdo-update-statement-wont-execute/#findComment-1488107 Share on other sites More sharing options...
ginerjm Posted August 18, 2014 Share Posted August 18, 2014 You have two where clauses in your query Quote Link to comment https://forums.phpfreaks.com/topic/290509-pdo-update-statement-wont-execute/#findComment-1488116 Share on other sites More sharing options...
jazzman1 Posted August 18, 2014 Share Posted August 18, 2014 You have two where clauses in your query Agreed, but the output is very strange: sql =UPDATE `emr_loanapplication` SET firstname = :firstname, secondname = :secondname, surname = :surname, officialworkemail = :officialworkemail WHERE username=:username Quote Link to comment https://forums.phpfreaks.com/topic/290509-pdo-update-statement-wont-execute/#findComment-1488124 Share on other sites More sharing options...
ginerjm Posted August 18, 2014 Share Posted August 18, 2014 I agree - obviously what is being posted is NOT the actual executed code. Quote Link to comment https://forums.phpfreaks.com/topic/290509-pdo-update-statement-wont-execute/#findComment-1488164 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.