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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.