紫影基地

 找回密码
 立即注册
查看: 856|回复: 0

[Mysql] Uncaught Error: Call to undefined function mysql_select_db()

[复制链接]
阅读字号:

2564

主题

2721

帖子

5万

积分

超级版主

Rank: 8Rank: 8

积分
59885
发表于 2022-10-27 09:14:14 | 显示全部楼层 |阅读模式

参考链接:
https://stackoverflow.com/questi ... ion-mysql-select-db
解决方案看下面:

    <?php  
    $username="root";  
    $password="namungoona";  
    $hostname = "localhost";  
    //connection string with database  
    $dbhandle = mysqli_connect($hostname, $username, $password)  
    or die("Unable to connect to MySQL");  
    echo "";  
    // connect with database  
    $selected = mysqli_select_db($dbhandle, "police")  
    or die("Could not select examples");  
    //query fire  
    $result = mysqli_query($dbhandle,"select * from News;");  
    $json_response = array();  
    // fetch data in array format  
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {  
    // Fetch data of Fname Column and store in array of row_array
    $row_array['Headlines'] = $row['Headlines'];  
    $row_array['Details'] = $row['Details'];
    $row_array['NewsPhoto'] = $row['NewsPhoto'];
    //push the values in the array  
    array_push($json_response,$row_array);  
    }  
    //  
    echo json_encode($json_response);
    mysqli_free_result($result);
    ?>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|紫影基地

GMT+8, 2025-1-27 10:41 , Processed in 0.191416 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表