mysql - PHP PDO Fetch not working? -


i can select object, cannot fetch rows database using following code, can see obvious errors?

    $sql2 = "select id, latitude, longitude, name countries";     $stmt2 = $pdo->prepare($sql2);     $stmt2->execute();      while ($row = $stmt2->fetch(pdo::fetch_assoc)) {         echo $countryid = $row->id;         echo $countryname= $row->name;         echo $longitude2 = $row->longitude;         echo $latitude2 = $row->latitude;     } 

the parameter pdo::fetch_assoc tells pdo return result associative array. can fetch array not object

 while ($row = $stmt2->fetch(pdo::fetch_assoc)) {         echo $countryid = $row['id'];         echo $countryname= $row['name'];          //rest of code      } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -