Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\MAMP\htdocs\twitter\tweet.php:48 Stack trace: #0 C:\MAMP\htdocs\twitter\tweet.php(48): PDOStatement->execute(Array) #1 {main} thrown in C:\MAMP\htdocs\twitter\tweet.php on line 48
J'ai vraiment besoin d'aide svp
Voici mon code en question, j'espère que vous pourriez m'aider.
<?php
session_start();
//require 'log.php';
try {
$database = new PDO('mysql:host=localhost;dbname=twitter2','root','root');
$database -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e){
die ('Site indisponible');
}
if(isset($_GET['id']) AND $_GET['id'] > 0)
{
$requser = $database->prepare('SELECT * FROM users WHERE id =?');
$requser->execute(array($_GET['id']));
$userinfo = $requser->fetch();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style2.css">
<title>Document</title>
</head>
<body>
<h1 id="twitter">BIENVENUE SUR TWITTER</h1>
<p>Profil de : <?php echo $userinfo['pseudo']; ?> </p>
<?php echo $_GET['id'];
?>
<?php require 'tweet_bar.php'; ?>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["post"] == "post_text"){
if(!empty($_POST["publication"])){
$send = $database->prepare('SELECT * FROM tweet');
$send->execute();
$postinfo = $send->fetch();
$send = $database->prepare("INSERT INTO tweet (id_users, posts, date_posts) VALUES (:id_users, :posts, :date_posts)");
$send->execute(array(
"publication" => $_POST["posts"] ?? "",
"id_users" => $_GET['id'] ?? "",
"date_posts" => $_POST["date_posts"] ?? ""));
} else{
echo "Pour publier vous devez écrire un message";
}
}
?>
</body>
</html>
<?php
}
?>