Maybe this is a duplicate question, but for all answers i found here and elswhere, i can't get it to work. I'm trying to update a few short php files which use mysqli to PDO to be future proof. I'm sending a value to the PHP file from out of Livecode, now this al worked with PHP and MySQL. But with PDO....not yet, i'm testing localhost the connection works:
<?php
//PDO
$servername = "localhost";
$username = "root";
$password = "";
try {
$pdo = new PDO("mysql:host=$servername;dbname=mydatabase", $username, $password);
// set the PDO error mode to exception
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully" . "<br />";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
Then this part is not working, it's not updating
<?php
//1. Create a database connection
$config = include_once "connect_database.php";
//2. Perform database query
$sql = "UPDATE `flash` SET `flashnews`= :flashnews WHERE `id`= :id";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':flashnews', $_POST["flashnews"], PDO::PARAM_STR);
$stmt->bindParam(':id', $_POST["id"], PDO::PARAM_INT);
$stmt->execute();
?>
Anyone has a clue what is wrong? thanks for any help on this.
Aucun commentaire:
Enregistrer un commentaire