If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / PHP warning error on Send Email to Customers

PHP warning error on Send Email to Customers

Started by sports_guy on 2 Dec 2012, 2:17 AM · Views: 1,278

Results 1 to 8 of 8
2 Dec 2012, 2:17 AM
#1
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Post #1 by sports_guy

I am not able to send e-mails in the admin control panel. When I go to Tools> Send Email my admin page is blank and I have this displaying in the window:

Send Email To Customers
  
WARNING: An Error occurred, please refresh the page and try again.

Obviously something is wrong, so I looked in my logs and found this on multiple dates:

[01-Dec-2012 16:33:51] PHP Warning:  constant() [<a href='function.constant'>function.constant</a>]: Couldn't find constant TABLE_SUBSCRIBERS in /MyRoot/public_html/store/includes/functions/audience.php on line 113
[01-Dec-2012 16:33:51] PHP Fatal error:  1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as s left join customers as c on c.customers_id = s.customers_id' at line 1 :: select c.customers_firstname, c.customers_lastname, s.email_address as customers_email_address from  as s left join customers as c on c.customers_id = s.customers_id   in /MyRoot/includes/classes/db/mysql/query_factory.php on line 120

I am not sure what was causing this so I overwrote my original: admin> email.php file just in case it was corrupt and I have the same issue.

In a previous installation I have had: newsletter_subscribe_2_2_2 so I likely still have these definitions in my database. I could not find the uninstall.sql that's why it's still in the database.
I also installed: FEC v1.10.0. I am not sure if this is related.

These are the only 2 modules that I think could have affected this (and maybe overwritten a core file). Any suggestions?

Building a better web, one site at a time: Dayton Web Design

2 Dec 2012, 1:46 PM
#3
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Post #3 by sports_guy

Thank you bislewl I obviously did not find that thread in my forum search. I appreciate your time.

Building a better web, one site at a time: Dayton Web Design

2 Dec 2012, 3:22 PM
#4
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Post #4 by sports_guy

The thread was closed so I could not post to it. As the 2 previous people had stated they removed the: "Newsletter Subscribers Only." I also removed the "Email test Group - Subscriber Only" since it seemed to be attached to the subscriber module.

I am still seeing the same error in my e-mail area of my control panel.

When I edit: "All Newsletter Subscribers" I see this query-string

select c.customers_firstname, c.customers_lastname, s.email_address as customers_email_address from TABLE_SUBSCRIBERS as s left join TABLE_CUSTOMERS as c on c.customers_id = s.customers_id 

How do I remove the table_subscribers (which I am assuming is left over from the old module)? Am I supposed to remove table_subscribers?

Last, I do not know how to do this:

The mod you said you removed has made a change to the queries in the query_builder table, adding a reference to the TABLE_SUBSCRIBERS table which you removed from your database.
You'll need to put back the original record for that record in the database.

This is what I have under query_builder:

query_id

query_category

query_name

query_description

query_string

1

email

All Customers

Returns all customers name and email address for s...

select customers_email_address, customers_firstnam...

2

email,newsletters

Customer Account Newsletter Subscribers

Returns name and email address of newsletter subsc...

select customers_firstname, customers_lastname, cu...

3

email,newsletters

Dormant Customers (>3months) (Subscribers)

Subscribers who HAVE purchased something, but have...

select o.date_purchased, c.customers_email_address...

4

email,newsletters

Active customers in past 3 months (Subscribers)

Newsletter subscribers who are also active custome...

select c.customers_email_address, c.customers_last...

5

email,newsletters

Active customers in past 3 months (Regardless of s...

All active customers (purchased something) in last...

select c.customers_email_address, c.customers_last...

6

email,newsletters

Administrator

Just the email account of the current administrato...

select 'ADMIN' as customers_firstname, admin_name ...

7

email,newsletters

Customers who have never completed a purchase

For sending newsletter to all customers who regist...

SELECT DISTINCT c.customers_email_address as custo...

8

email,newsletters

All Newsletter Subscribers

Returns name and email address of all Customer Acc...

select c.customers_firstname, c.customers_lastname...

11

email,newsletters

Email Test Group - Customers

Returns name and email address of Newsletter-only ...

SELECT c.customers_email_address as customers_emai...

12

email,newsletters

Permanent Account Holders Only

Send email only to permanent account holders 

select customers_email_address, customers_firstnam...

I am afraid to remove anything without some advice.

Building a better web, one site at a time: Dayton Web Design

2 Dec 2012, 10:36 PM
#5
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Post #5 by sports_guy

I have another installation of Zen Cart without the newsletter module installed. The only problem is the install is Zen version is 1.3.9h. I can go to the PHPMyAdmin and find the "query_builder" tables and copy or duplicate these directly into my newer installation (v1.5.1) to match the other installation. Is this advised?

Building a better web, one site at a time: Dayton Web Design

2 Dec 2012, 11:28 PM
#6
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Post #6 by sports_guy

OK. I was able to fix this issue. For those of you that have this same problem, you have to delete tables that newsletter_subscribe adds, to a certain area of your database. Go to your hosting control panel>PHP MyAdmin and find your database. Once you click on your stores database, find a main table called: "query_builder". Click on this and you will see all the queries related to this table.

You only need 7 of these tables (at least up to v1.5.1) and these are the tables:

1 (query_id), email (query_category),All Customers (query_name), Returns all customers name and email address for s...(query_description)
2 (query_id), email,newsletters (query_category),Customer Account Newsletter Subscribers (query_name), Returns all customers name and email address for s...(query_description)
3 (query_id), email,newsletters (query_category),Dormant Customers (>3months) (Subscribers) (query_name), Subscribers who HAVE purchased something, but have...(query_description)
4 (query_id), email,newsletters (query_category),Active customers in past 3 months (Subscribers) (query_name), Newsletter subscribers who are also active custome...(query_description)
5 (query_id), email,newsletters (query_category),Active customers in past 3 months (Regardless of s... (query_name), All active customers (purchased something) in last...(query_description)
6 (query_id), email,newsletters (query_category),Administrator (query_name), Just the email account of the current administrato...(query_description)
7 (query_id), email,newsletters (query_category),Customers who have never completed a purchase (query_name), For sending newsletter to all customers who regist...(query_description)

Your store creates tables called: query_id and numbers them 1-7. **The newsletter module added tables 8-12. Just delete tables 8-12 and your e-mail system will work.
**
A couple of notes:

First, while my query_names. and query_descriptions changed between version 1.3.9h and 1.5.1 (or the newsletter module changed them) the most important factor called the "query_string" was identical for tables 1-7. Another words the module does not affect these tables (1-7). What I am saying is you should not have to touch table 1-7 just leave them be.

Second, this is only for MySQL databases. If you have a Windows server it might be different.

Third, this should fix any issues that is related to this old newsletter module migrated into the new store (v1.5.1). My errors were slightly different than the other post above. But I removed the old tables like they did and mine also worked.

Last, I know nothing about databases so if I can do this anyone can. Just make a backup of your database and store before deleting these tables.

Hope this helps someone who is having issues, but afraid to modify them directly in phpMyAdmin for your database.

Building a better web, one site at a time: Dayton Web Design

5 Jan 2013, 2:30 PM
#7
saplanet avatar

saplanet

New Zenner

Join Date:
Jun 2008
Location:
Singapore, Australia, America
Posts:
97
Plugin Contributions:
0

Post #7 by saplanet

I had newsletter_only installed before on 1.39h; now I am running on V1.5.1 engine, and also encounter the same problem.

In the logs, the debug file states:
[05-Jan-2013 21:55:49] PHP Fatal error: 1065:Query was empty :: in /public_html/includes/classes/db/mysql/query_factory.php on line 120

I have deleted one line as shared by the sportsguy, but it still didn't work. Anyone knows what to do with this?

17 May 2013, 1:06 AM
#8
pixelpadre avatar

pixelpadre

Suspended

Join Date:
Jun 2007
Location:
Eustis, Florida, USA, EARTH
Posts:
868
Plugin Contributions:
0

Post #8 by pixelpadre

Love it when I dont have to ask a question to get my solution.

ZC v1.5.7 "I was so much older then...I'm younger than that now" Cut the umbilical cord with webhosts after 20 years. FREEDOM!