Uncaught Error: Call to undefined function mysql_select_db()

女爷i 2022-03-21 12:56 763阅读 0赞

参考链接:
https://stackoverflow.com/questions/40650747/uncaught-error-call-to-undefined-function-mysql-select-db
解决方案看下面:

  1. <?php
  2. $username="root";
  3. $password="namungoona";
  4. $hostname = "localhost";
  5. //connection string with database
  6. $dbhandle = mysqli_connect($hostname, $username, $password)
  7. or die("Unable to connect to MySQL");
  8. echo "";
  9. // connect with database
  10. $selected = mysqli_select_db($dbhandle, "police")
  11. or die("Could not select examples");
  12. //query fire
  13. $result = mysqli_query($dbhandle,"select * from News;");
  14. $json_response = array();
  15. // fetch data in array format
  16. while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
  17. // Fetch data of Fname Column and store in array of row_array
  18. $row_array['Headlines'] = $row['Headlines'];
  19. $row_array['Details'] = $row['Details'];
  20. $row_array['NewsPhoto'] = $row['NewsPhoto'];
  21. //push the values in the array
  22. array_push($json_response,$row_array);
  23. }
  24. //
  25. echo json_encode($json_response);
  26. mysqli_free_result($result);
  27. ?>

发表评论

表情:
评论列表 (有 0 条评论,763人围观)

还没有评论,来说两句吧...

相关阅读