1

I have been working on this issue for the past few days.

PHP Fatal error: Column 'country_code' cannot be null in /home/jharvard/vhosts/pset8/includes/functions.php on line 57

initially i had defined my database insertion check-loop condition to be: while ($line = fgetcsv($usfile, 0, "\t") !== false)

but after using (as per the man page for fgetcsv): while (($line = fgetcsv($usfile, 0, "\t")) !== FALSE)

I got my "import" file working

My question here is,what is the difference between these loops:

while (($line = fgetcsv($usfile, 0, "\t")) !== FALSE)

while ($line = fgetcsv($usfile, 0, "\t") !== FALSE)

1 Answer 1

1

The secret lies in operator precedence and implicit casting. Because the comparison operator !== has a higher precedence than the assignment operator =, $line is cast as a boolean when you use while ($line = fgetcsv($usfile, 0, "\t") !== false). The additional parentheses force the assignment operator to have precedence, thus casting $line as an array.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .