Prepared Statement / MySql

Bonjour,

Voilà j'essaye de mettre en place un preparedStatement dans mes scripts php.

Le voici :
$bdd=new PDO("'mysql:host=localhost;dbname=*****','****','****' ");
$stmt=$bdd->prepare("select distinct :contactcol from appli_tresorie.transaction order by :contactord");
$stmt->bindParam(':contactcol', $contact);
$stmt->bindParam(':contactord', $contact);
$contact=$_GET['contact'];
$stmt->execute();
$array = $stmt->fetchAll();


Mais voila mon script ne passe pas et je ne sais pas pourquoi !

Si vous avez des réponses

Merci !

5 réponses

  1. Salut !

    $stmt->bindParam(':contactcol', $contact);
    $stmt->bindParam(':contactord', $contact);
    $contact=$_GET['contact'];

    Tu utilises $contact avant de l'avoir initialisé ;-)
    1. Oui c'est pas faux ! xD
      Mais ça ne marche toujours pas ce $contact = ... était une précaution (certes raté ^^')

      Mais il est aussi déclaré au début de la page :s
      1. Tu as des erreurs ?
        Si non, essaye avec ca :
        $stmt->execute() or die(print_r($stmt->errorInfo()));

        Jérémy
        1. Toujours le même problème :

          NetworkError: 500 Internal Server Error (l'erreur qui ne veut rien dire quoi xD)
          1. Met le new pdo dans un try catch pour voir si l'erreur vient de la connexion à la bdd.
            Un petit print_r($array) sinon