Basically what I'm trying to do is load all the emails that are in a database and insert them into an array. But since printf outputs in length of the string I have no clue how to do it. I know this is probably something very basic but, yeah. I'm kindof new to php. Any idea's?
<?php
$emails = array();
mysql_connect("127.0.0.1", "root") or
die("Could not connect: " . mysql_error());
mysql_select_db("users");
$result = mysql_query("SELECT email FROM users");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$email = printf("%s", $row[0], $row[1]);
}
mysql_free_result($result);
?>
mysql_database extension in new code a Kitten is strangled somewhere in the world it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning thePDOormysqlidatabase extensions and prepared statements. Start hereSELECT email ..., then... $row[0], $row[1]);. Can you spot the error? You're selecting one column but fetching data of two columns.mysql_connect()is missing a parameter so the rest of the code is irrelevant. If you are learning PHP start with PDO dont waste time on themysql_extension it is dead