0

I don't know what's wrong with my code. There is an error:

Parse error: syntax error, unexpected T_NS_SEPARATOR, expecting T_STRING in /home/&&&&/public_html/oscommerce/admin/modules.php(313) : eval()'d code on line 1

This is the Line 313

eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");

Values:

$value['set_function'] contains tep_cfg_select_option(array('Live', 'Sandbox'),

$value['value'] contains Live

$key contains CONFIGURATION_PAYPAL

Jocelyn
  • 11,209
  • 10
  • 43
  • 60
Ken
  • 833
  • 2
  • 13
  • 27
  • the problem is, that your string is not properly ended/escaped. could be that you forgot a "(" after the [set_function] array)... but because I dont know whats inside those variables i dont have a clue – Najzero Feb 07 '13 at 13:17
  • We need to know what `$value` and `$key` contain. Also, why are you using `eval()`? It is rare that you actually need to use it, and when you use it it almost always causes problems. – Sverri M. Olsen Feb 07 '13 at 13:22

4 Answers4

1

Are you absolutely sure you want to use eval()?

PHP documentation for eval() says

The eval() language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have carefully verified that there is no other option than to use this construct, pay special attention not to pass any user provided data into it without properly validating it beforehand.

Mike
  • 1,158
  • 5
  • 22
  • 32
0

One possible reason is that the parenthesis don't seem to match. You have 2 ) at the end while you only have one ( .

WEFX
  • 8,298
  • 8
  • 66
  • 102
phpalix
  • 679
  • 4
  • 8
0

eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");

Will give you something like

$keys .= set_function'value', 'key');

That's not correct I believe.

How about adding ( after $value['set_function'] . " ? You haven't opened the bracket after name of the function.

Another thing is that T_NS_SEPARATOR error means that you have \ somewhere where it shouldn't be. Per: https://stackoverflow.com/a/6454891/2028547 - see the values of all your variables for weird characters.

Community
  • 1
  • 1
MarcinWolny
  • 1,600
  • 2
  • 27
  • 40
  • but the ( could be in `$value['set_function']` – Mez Feb 07 '13 at 13:19
  • I doubt anyone is stupid enough to store bracket with a function name under a variable called "set_function" (no offence). – MarcinWolny Feb 07 '13 at 13:21
  • You never know - considering the error that he's receiving (NS_SEPERATOR) it looks like the error is actually something to do with bad escaping. – Mez Feb 07 '13 at 13:25
  • Ok, so basically two things to do: Get rid of brackets from variable storing function name (as it should store ONLY function name) and then look into special characters, especially backslash. – MarcinWolny Feb 07 '13 at 13:32
  • I found it out.. after echoing `$value['set_function']` it displays slashes yet there is no slashes on value itself.. – Ken Feb 07 '13 at 13:51
  • @Ken - try running this regular expression on your `$value['set_function']` http://stackoverflow.com/a/6073257/2028547 – MarcinWolny Feb 07 '13 at 15:00
0

Looks like whatever is in $value['set_function'] or $value['value'] or $key have a \ in them

Try echoing what's in eval() rather than running eval() - this will let you see the code PHP is trying to run.

The error is basically saying that there's a namespace seperator (\) in a strange place within the eval()'d code

Mez
  • 24,430
  • 14
  • 71
  • 93