0

I get this Undefined offset: 0

$lasttrade = BaseDonnee::execQuery($bdd, "SELECT Price FROM Trade_History WHERE 
Market='$ipair' ORDER BY Timestamp DESC LIMIT 1")[0]["Price"];

What is this problem? and how do I solve this? the BaseDonne::execQuery function is this

static function execQuery($bdd, $query){
try{
    $req = $bdd->prepare($query);
    $req->execute();
    $result = $req->fetchAll(PDO::FETCH_ASSOC);
    $req->closeCursor();
    return $result;
} catch( PDOEXception $e ) {
       echo $e->getMessage(); // display bdd error
       exit();
   }


}
Manish
  • 133
  • 9
  • That means you aren't getting any results – John Conde Mar 16 '18 at 12:35
  • Yes, but why no results. – Manish Mar 16 '18 at 12:36
  • 2
    You tell *us*. We don't know your system or data. Have you bothered to run this query against your DB? Do you get results? Are you sure this query is right? Does the variable in your query which leaves you open to SQL injection have a value? Is it what you expected? This is all basic troubleshooting. – John Conde Mar 16 '18 at 12:37
  • This isn't my system. I downloaded it via github, to run and understand bitcoin trading. It's only been an hour and have been trying to get rid of a few bugs :) – Manish Mar 16 '18 at 12:47

0 Answers0