You get a bonus - 1 coin for daily activity. Now you have 1 coin

PDO PHP MySQL UPDATE Not Working

Practice




PDO PHP Mysql UPDATE isn't working

$sql=" UPDATE _bill SET post = NOW() WHERE id=$id" ;

var_dump( $pdo->ex ec($sql));


and like this

$sql=" UPDATE _bill SET post = NOW() WHERE id=$id" ;

var_dump( $pdo->prepare ($sql)->exe cute());



and even like this

$sql=" UPDATE _bill SET post = NOW()" ;

var_dump( $pdo->prepare ($sql)->ex ecute());

check the initialization — make sure autocommit isn't disabled

$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// PDO::ATTR_AUTOCOMMIT => false
);

try
{
$pdo = new PDO($database_dsn, $database_user, $database_password, $opt);
}
catch (PDOException $e)
{
die('Connection failed: ' . $e->getMessage());
}

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)