I've moved to a new server with a current version of PHP, have updated WordPress to 4.5.2 and updated CiviCRM to 4.7.7. I still get this error when exporting selected records from an Advanced Search:

Warning: strpos(): Empty needle in /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Export/BAO/Export.php on line 709

Warning: Cannot modify header information - headers already sent by (output started at /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Export/BAO/Export.php:709) in /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 895

Warning: Cannot modify header information - headers already sent by (output started at /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Export/BAO/Export.php:709) in /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 895

Warning: Cannot modify header information - headers already sent by (output started at /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Export/BAO/Export.php:709) in /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 895

Warning: Cannot modify header information - headers already sent by (output started at /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Export/BAO/Export.php:709) in /home/zoweh/public_html/allied/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 895 "Contact ID","Contact Type","Contact Subtype","Do Not Email","Do Not Phone","Do Not Mail","Do Not Sms","Do Not Trade","No Bulk Emails (User Opt Out)","Legal Identifier","External Identifier","Sort Name","Display Name","Nickname","Legal Name","Image Url","Preferred Communication Method","Preferred Language","Preferred Mail Format","Contact Hash","Contact Source","First Name","Middle Name","Last Name","Individual Prefix","Individual Suffix","Formal Title","Communication Style","Job Title","Gender","Birth Date","Deceased","Deceased Date","Household Name","Organization Name","Sic Code","Unique ID (OpenID)","Current Employer ID","Contact is in Trash","Created Date","Modified Date","Addressee","Email Greeting","Postal Greeting","Current Employer","Location Type","Street Address","Street Number","Street Number Suffix","Street Name","Street Unit","Supplemental Address 1","Supplemental Address 2","City","Postal Code Suffix","Postal Code","Latitude","Longitude","Address Name","Master Address Belongs To","County","State","Country","Phone","Phone Extension","Email","On Hold","Use for Bulk Mail","Signature Text","Signature Html","IM Provider","IM Screen Name","OpenID","World Region","Website","Group(s)","Tag(s)","Note(s)","Phone Type","IM Service Provider"

It then lists each of the records selected in the same format...

  • 1
    I edited out your example person's name and street address in case it was a real person. :) Commented May 4, 2016 at 0:14
  • This seems to be related to your search terms. If it worked previously, it's definitely a bug - but hard to figure out unless it can be replicated. Can you share the search terms? Can you replicate it on the demo server at demo.civicrm.org? Please update your question with those details and folks can help! Commented May 4, 2016 at 14:03
  • My search was a Postal Code range and resulted in 221 records. I attempted to export all 221 and get that error. At demo.civicrm.org I was able to do a range that resulted in 4 records and the export worked. The demo site is running 4.7.8 so perhaps there is a fix, but I hadn't attempted to upgrade because my site says it is current. The demo site also "meets or exceeds" the minimum recommendation for PHP whereas mine simply meets the minimum but not the recommended version of PHP. Perhaps therein lies the problem. Commented May 5, 2016 at 14:39
  • I upgraded to 4.7.7 which is available and I get more than the one record following the same error messages, now. In other words, still a problem. Perhaps it is a PHP issue. Thoughts? Commented May 5, 2016 at 18:17
  • And thank you Allen Hutchison for your edit. Commented May 6, 2016 at 14:55

1 Answer 1


This is a bug in CiviCRM. I can replicate the issue on my database using v4.7.

Basically what is happening is that if a sort order isn't defined, the $order variable is NULL which throws off the strpos() function and sends the error message which then triggers the "headers already sent" errors.

See this post about why the $order variable was changed: https://forum.civicrm.org/index.php?topic=36040.0

This post "Empty needle" error when exporting from Advanced Search results provides a quick fix by hiding error messages.

I've submitted an issue to CiviCRM: https://issues.civicrm.org/jira/browse/CRM-19212

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.