I am trying to build a newsletter. The user has to fill a form where $emaila is his email.
<?php
$emaila="[email protected]";
$con=mysqli_connect("localhost","user","pass","dbname");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$val = mysqli_query("select $emaila from emails limit 1");
if($val !== FALSE)
{
mysqli_query($con,"ALTER TABLE emails ADD (".$emaila." VARCHAR(100))");
mysqli_close($con);
}
?>
It suposes to check if the email is already in the table "emails" as column, and if it isn't, it should put his email in the table as column. Not sure what I did wrong...
[email protected]is that really a column?$val = mysqli_query("selectno connection hereselect $emaila from emailstranslates toselect [email protected] from emails. Check for errors on the queriesmysqli_error($con)and you'll see. But that never happens because you didn't pass connection to the query..csvfile in Excel and modify it, and then reimport into phpmyadmin somehow, or parse it with PHP php.net/manual/en/function.fgetcsv.php. See also stackoverflow.com/q/16391528/1415724 and mysqltutorial.org/mysql-export-table-to-csv