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
| <!DOCTYPE html>
<body>
<?php
function db(){
$x='xxxxxxxxxx';
$y='xxxxxx';
$z='xxxxxxxx';
$o= array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
$db=new PDO($x,$y,$z,$o);
return $db;
}
function requete($db,$id){
$s="SELECT user_id FROM perso_candidature WHERE id =?";
$r=$db->prepare($s);
$r->execute(array($id));
while($w=$r->fetch(PDO::FETCH_OBJ))
{
$uid=$w->user_id;
}
echo $uid;
}
$db=db();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
requete($db,102);
$db=NULL;
?>
</body>
</html> |
Partager