News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

How to Enable / Disable eval()

Started by N3RVE, February 03, 2009, 07:38:28 AM

Previous topic - Next topic

N3RVE

You might want to see: Why does SMF use eval()?


Let me guess, you are reading this topic because you've been asked to enable / disable eval()?
When eval() is used, errors reported in templates and other files might not actually be happening there. So you might need to disable eval() temporarily to get accurate errors.

To do that, open phpMyAdmin (What is phpMyAdmin?), select your forum database and run this query:

Code (Disable) Select
REPLACE INTO smf_settings VALUES ('disableTemplateEval', 1);

Empty the Forum Error Log from Admin Control Panel > "Forum Error Log" and wait for new errors. The newly generated errors should be different and should point out where exactly the errors are happening. Copy those errors and post them where you've been asked to and run the following query to enable eval()

Code (Enable) Select
REPLACE INTO smf_settings VALUES ('disableTemplateEval', 0);

The SQL queries above work if the database tables prefix for your forum is smf_ (which is the default). The actual prefix for your forum can be found in the Admin CP -> Server Settings -> "Database Tables Prefix" or as the value for $db_prefix in Settings.php (which is located in your forum directory).


To run each of the queries, click on the SQL link at the top of the right pane (see the image below), enter the query in the box and click the Go button.



Do *not* post support request here, please, start a new topic with your query :)

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

shadow82x

Nice tutorial [n3rve]. This will help the many support topics that ask for assistance on this. :P
Colin B
Former Spammer, Customize, & Support Team Member

N3RVE

Thanks Shadow82x, I've had to reply with these instructions to quite a lot of support topics recently and thought it'll help to have it posted ;)

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

aw06

What happens if i leave eval disabled ??
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

N3RVE

#4
Quote from: aw06 on February 12, 2009, 03:49:55 PM
What happens if i leave eval disabled ??

eval() simply executes the specified string as PHP code. Since file_get_contents() returns the contents of a file as a string, this allows SMF to track down the specific code that's causing a parse error, and consequently output a pretty color-coded error message showing you the code that's causing the problem.

The downside to using eval() is that PHP doesn't really know where an "undefined" error occurred. By switching eval() off, SMF uses require() (or, more often, require_once()) to get the template file. This in turn lets PHP report the exact location of the error.

Hope that clears things up for you :)

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

C4G-TK

OK, I got it disabled correctly, but now I can't get it to enable again!!  LOL

I ran the query, but I get this message:

SQL query:

INSERT INTO channel4gaming_com_c4g_settings
VALUES (
'disableTemplateEval', 0
)

MySQL said: Documentation
#1062 - Duplicate entry 'disableTemplateEval' for key 1

-img removed-

C4G-TK

#6
Quote from: [n3rve] on February 03, 2009, 07:38:28 AM
Empty the Forum Error Log from Admin Control Panel > "Forum Error Log" and wait for new errors. The newly generated errors should be different and should point out where exactly the errors are happening. Copy those errors and post them where you've been asked to and run the following query to enable eval()

Code (Enable) Select
INSERT INTO smf_settings VALUES ('disableTemplateEval', 0);


Ummm, shouldn't the 2nd query be  enableTemplateEval instead of disable?  Because otherwise, I keep getting an error and it won't correctly do the query.

ok maybe not... help!   ??? ???

-img removed-

Fustrate

#7
I edited it to use REPLACE INTO instead of INSERT INTO, so that this can be done more than once.

;)
Steven Hoffman
Former Team Member, 2009-2012

heavyccasey

Thank you, this sped up my forum by a noticeable amount (I use an accelerator).

Sarge

Quote from: heavyccasey on April 18, 2009, 02:46:09 AM
Thank you, this sped up my forum by a noticeable amount (I use an accelerator).

I'm curious... what sped up your forum, enabling or disabling eval?

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Fustrate

Probably disabled, since it's enabled by default.
Steven Hoffman
Former Team Member, 2009-2012

Neighbours-Unite

Quote from: [n3rveThe SQL queries above work if the database tables prefix for your forum is smf_ (which is the default). The actual prefix for your forum can be found in the Admin CP -> Server Settings -> "Database Tables Prefix" or as the value for $db_prefix in Settings.php (which is located in your forum directory).

-[n3rve]

But what if the tables prefix isn't smf_?
What if that is left blank like this  $db_prefix = '';
MIght that start causing problems in the future?
I tried to change it so it said smf_ but everything whent down then so had to change it back.

N3RVE

Just run: REPLACE INTO settings VALUES ('disableTemplateEval', 1);

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

abidejaz4u

in there show like this



full image
click here

where i can put that Query

N3RVE

SQL, see the screenshot above.

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Arantor


Marthless

Hello, whether somebody can say where I will find with the one options REPLACE INTO smf_settings VALUES ('disableTemplateEval', 1);. ?

I will add that in smf_settings I don't have it.
I ask you for the help in solving this problem. Because no longer I know what is not this way.

I will be very grateful for it. :)

Masterd

This is a query. You need to run it in the phpMyAdmin query section. Maybe your database prefix is not smf_.

MrPhil

I think the statement was that "disableTemplateEval" isn't found in his smf_settings. That's OK. It is suggested to do a REPLACE instead of an INSERT in case that entry has already been added -- you don't want two copies of it. If it doesn't already exist, REPLACE will act like INSERT.

By the way, there is a mod (2054) that gives you an admin switch to do this more easily.

Masterd

Quote from: MrPhil on January 09, 2011, 10:24:15 PM
By the way, there is a mod (2054) that gives you an admin switch to do this more easily.

Quote from: IncognitoMuse on August 09, 2009, 01:47:03 PM
You can also use this mod: http://custom.simplemachines.org/mods/index.php?mod=2054 to add a UI item to both 1.1 and 2.0.

Advertisement: