i want to fetch a mysql table named "my_table" column named "Email" contents as an array by php , so this is my code :
<?php
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "my_table";
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $result = mysql_query("SELECT * FROM my_table");
    if ($result === FALSE) {
        die(mysql_error()); // TODO: better error handling
    }
    $data = array();
    while ($row = mysql_fetch_array($result)) {
        $data[] = $row['Email'];
    }
    echo join($data, ',');
?>
but this code returns me this error : No database selected
but i've selected my table and database ...
and i know this code have some problems as mixing mysql and mysqli content but i dont know how to fix it i just want that array echo , if this code need to be fixed just guid me , how to solve this problem ? thanks in advance Thanks to @Martin my problem has solved i just changed the code by this way :
<?php
$servername = "localhost"; $username = "root"; $password = ""; $dbname = "my_db"; 
// Create connection
 $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection 
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);}
$result = mysqli_query($conn, "SELECT * FROM my_table");
if($result === FALSE) { 
die(mysql_error()); // TODO: better error handling
}
$data = array();
while ($row = mysqli_fetch_array($result))
{
$data[] = $row['Email'];
}
echo join($data, ',')
?>
 
     
    