Welcome to WebmasterWorld Guest from 54.159.190.106

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

unset command causing parse errors

   
5:08 am on Jan 16, 2004 (gmt 0)

10+ Year Member



Everytime I run a php page with an unset command my server is generating a parse error. Is there something in either the php.ini or an .htaccess file that I need to turn on/off or initialize?

Thanks,
cgallent

2:56 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



What are you trying to unset? Or more importantly, how are you using unset() [php.net]?

Note that in PHP 3, unset() will always return
TRUE
(actually, the integer value 1). In PHP 4, however, unset() is no longer a true function: it is now a statement. As such no value is returned, and attempting to take the value of unset() results in a parse error.

The User Contributed notes also makes a good statement:

As of PHP version 4.3.3, unset() results in a parse error if it is used with the @ error suppression operator.

For example:

@unset($var); // parse error
unset(@$var); // parse error
unset($var); // okay

This is because the @-operator works only on expressions [php.net]. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. (Error Control Operators [php.net])

3:22 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



I'm not trying to unset anything. What is happening is that I have two php applications that I've installed - one widely used BB. I have them installed on other servers and they work absolutely flawless.

I just setup my own VPS and have uploaded these and in each case the only error that I'm getting is the parse error on the unset command.

My thought is that it's something in the php.ini that's turned off/on or not set properly.

4:15 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



>>I'm not trying to unset anything.

I'm referring to the unset [php.net] statement in PHP. This is what seems to be giving you the parse error.

What version of PHP are each of the servers running? PHP 3 treated

unset
as a function and as of PHP Version > 4,
unset
is a statement. This may be your issue. Read my last post carefully now that you understand what I mean by
unset
. Sorry for the confusion.

If possible, find the line giving the error and post it for us to take a look at. Also, the version of PHP on the server is important regarding how the statement is being used.

4:58 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Here's one:

unset($block_names[$block_nesting_level]);

I've looked at the others and they're all written the same.

Server:
Apache 1.3.29
PHP 4.3.3

Ideas?

5:26 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Well the syntax looks fine for PHP 4.3.3.

Are you sure that

unset
is the actual problem? Parse errors [php.net] can be tough to find sometimes. They usually occur when you are missing a closing semicolon or brace. Can you post the exact error message you are getting?
6:24 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Parse error: parse error in /home/musiccit/public_html/members/bb/includes/template.php on line 356

That's the line that I've included.

Thanks for the help to date - I really appreciate it.

7:22 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Could it be a missing semicolon on the preceding line?
7:57 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I don't think this has anything to do with
unset
. The reason I make this statement was a quick search on google for phpbb "template.php on line 356" and you'll see what I mean.

I'm guessing that either your template.php file has been modified or changed or else the $code variable that is being passed to the

compile
function within that script is the issue. If all you did was transfer the same template.php from one server to your new server, I'd double check that $code variable and how it is being processed within the
compile
function step by step until you nail down what is causing the problem. There is a developer note in there stating that some funky things might happen if you have a #<!-- BEGIN (.*?) --># and an #<!-- END (.*?) --># on the same line.
9:27 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



I got it fixed. I had to upgrade to php v4.3.4 and that took care of it.

Thanks a ton for the input.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month