Ho provato a fare così e funziona:
codice:
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT i.emailaddress, d.openip FROM email_list_subscribers i, email_stats_emailopens d where i.subscriberid = d.subscriberid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<br> id: ". $row["subscriberid"]. " - Name: ". $row["emailaddress"]. " " . $row["openip"] . "<br>";
fclose($file);
}
} else {
echo "0 results";
}
$conn->close();
?>
Poi ho provato a farlo scrivere su un file di testo, ma non funziona più
codice:
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT i.emailaddress, d.openip FROM email_list_subscribers i, email_stats_emailopens d where i.subscriberid = d.subscriberid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$file = fopen("test.txt");
echo fwrite($file,"<br> id: ". $row["subscriberid"]. " - Name: ". $row["emailaddress"]. " " . $row["openip"] . "<br>");
fclose($file);
}
} else {
echo "0 results";
}
$conn->close();
?>