0
for($i=0;$i<=feof($getdata);$i++)
{
if (filter_var($data[$i][1], FILTER_VALIDATE_EMAIL)){
echo $data[$i][1];
$email=$data[$i][1];
$conn = mysqli_connect($dbhost,$dbuser,$dbpass, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
$sql ="INSERT INTO promo_user (uid,name,email) VALUES (,'', '$email')";
mysqli_query($sql,$conn);
mysqli_close($conn);

i am using the above code but there is something wrong with it,whenever i run the code the echo is working fine but the content does go into sql table

Please help

santosh m
  • 17
  • 5

1 Answers1

1

You have the arguments transposed - the correct order is

mysqli_query($con,$query)

So the first parameter of mysqli_query will be the connection and second is query.

Also, you can make connection outside the loop, so connection will be initiated only one time.

Toby Speight
  • 27,591
  • 48
  • 66
  • 103