fork download
  1. <?php
  2.  
  3. $language = "es";
  4. $active = 1;
  5.  
  6. $stmt = $con->prepare("SELECT url,cover_page,alt_img,mini_title,mini_description,date_post FROM news_sport WHERE language=? AND active=? order by id_news_sport DESC limit 2");
  7. $stmt->bind_param("si",$language,$active);
  8. $stmt->execute();
  9. $stmt->store_result();
  10.  
  11. $dbData = array();
  12. $stmt->bind_result(
  13. $dbData['url'],
  14. $dbData['cover_page'],
  15. $dbData['alt_img'],
  16. $dbData['mini_title'],
  17. $dbData['mini_description'],
  18. $dbData['date_post']
  19. );
  20.  
  21. $valor = "";
  22. while ($stmt->fetch()) {
  23. $noticias = json_encode($dbData);
  24. $valor .= $noticias;
  25. }
  26.  
  27. echo $valor;
Runtime error #stdin #stdout #stderr 0.02s 24608KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined variable: con in /home/JkXP7p/prog.php on line 6
PHP Fatal error:  Uncaught Error: Call to a member function prepare() on null in /home/JkXP7p/prog.php:6
Stack trace:
#0 {main}
  thrown in /home/JkXP7p/prog.php on line 6