0

I am trying to compare an email from a CSV file from facebook with the email list in my mysql database.

But when i try to query the sql, nothing happens..

if I echo the email and copy past the email into the query string, then there is not problem.

So what is it I'm doing wrong?

<?php
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        $row++;
        for ($c = 0; $c < $num; $c++) {
            $array[] = $data[$c] . "<br />\n";
        }
    }
    fclose($handle);
}

$place = explode("  ", $array['94']);

$email = $place['11'];


$x = mysqli_query($mysql_link, "SELECT * FROM `dagenshug_newsletter_subscribe` WHERE mail_address = '" . $email . "'");
while ($row = mysqli_fetch_assoc($x)) {
    $haha[] = $row;
}

print_r($haha);

?>

$place['11'] contains the mail

UPDATE:

I tried to insert it into my database, and here is the result

j a c o b s e n @ g m a i l . c o m

3
  • First, the var: $email is undefined (you should set instead of echoing it). For print arrays, use var_dump() instead of print_r. Commented May 22, 2017 at 16:33
  • Somewhere before your SELECT, you need to set $email = $place[11]; Commented May 22, 2017 at 16:53
  • mistake, because i was testing.. i was trying $email = $place[11].... and even put the $place['11'] into the string.. not working Commented May 22, 2017 at 18:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.