Probleme dans la requête update
salut tous
je suis débutante (take me easy) alors je suis entrain de faire une requête UPDATE avec l'utilisation d' un resulta du SELect au debut jai utilisé une seule requete et ca na pas marché il faut faire un tabl temporaire (car on peut pas modifier la meme ligne dont on selecte ) dou je l'ai composé en 2 sous requête Object of class PDOStatement could not be converted to string
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
<?php
if (isset($_POST['confirm'] ))
{
$nomMentee= $_POST['nameMentee'] ;
$nomMentor = $_POST['nameMentor'] ;
if (( $nomMentee) && ( $nomMentor ) )
{
include_once 'connexion.php' ;
try {
try {
$sql1='select id from user where nomprenom= "'.$nomMentor.'" ' ;
$stmt1 = $databaseConnection->query($sql1);
}
catch(PDOException $e){
echo $sql . "<br>" . $e->getMessage();
}
$sql = 'UPDATE user set Mentor = '.$stmt1.' // quest ce que je mets ici cest un entiier pas string
where nomprenom = "'.$nomMentee .'" ' ;
// Prepare statement
$stmt = $databaseConnection->prepare($sql);
// execute the query
$stmt->execute();
// echo a message to say the UPDATE succeeded
echo $stmt->rowCount() . " records UPDATED successfully";
}
catch(PDOException $e){
echo $sql . "<br>" . $e->getMessage(); }
$databaseConnection = null;
}
}
//header ('Location : tablo.php') ;
?> |
merci de m'aider i need it reaaly