I have a script to update some user information automatically. Here is the section I use to update the DB. The variables are defined and valid.
try {
$MyDBConn = new PDO("mysql:host=localhost;port=3306;dbname=$MyDBName", $MyDBUser, $MyDBPass);
// PDO can throw exceptions rather than Fatal errors, so let's change the error mode to exception
$MyDBConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$MySQL = "UPDATE jos_jsn_users SET grading = '$MyFLTTRanking' WHERE fltt_license like '%$MyFLTTLicense'";
$MyStmt = $MyDBConn->prepare($MySQL);
$MyStmt->exec(); //error is here
$MySQL = "UPDATE jos_jsn_users SET grading_points = '$MyFLTTRankingPoints' WHERE fltt_license like '%$MyFLTTLicense'";
$MyStmt = $MyDBConn->prepare($MySQL);
$MyStmt->exec();
$MyDBConn = null;
// $output = shell_exec($MyWorkDir."bin/dbupdate_users.sh $MyFLTTLicense $MyFLTTRanking $MyFLTTRankingPoints");
}
catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage()."\n";
}
When I run the script, I get this error:
PHP Fatal error: Uncaught Error: Call to undefined method PDOStatement::exec() .. #0 {main} thrown in (file)
The linenumber points to the first statement $MyStmt->exec();
What or where did I wrong?