LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2006, 12:16 PM   #1
jason1074
LQ Newbie
 
Registered: Sep 2006
Posts: 7

Rep: Reputation: 0
Help, What's the meaning of this Parse error??


Can somebody please help me? What's the meaning of this Parse error?

The Parse error reads:
syntax error, unexpected T_IF in /home/shoutout/public_html/thumb/class.php on line 1043

Below are lines 1042,1043 and 1044.


{
$GIFtemp = if ($this->getimagesizeinfo[2] == 1);
$ImageCreateFunction = ($GIFtemp ? 'ImageCreateFromGIF' : 'ImageCreateFromPNG');



Thank you,
Jay
 
Old 09-29-2006, 12:47 PM   #2
i_grok
Member
 
Registered: Jun 2006
Location: Massachusetts
Distribution: Gentoo
Posts: 79

Rep: Reputation: 16
You can't have an if() statement with a semicolon after it. You should have something like this:
Code:
if($this->getimagesizeinfo[2] == 1) {
  $ImageCreateFunction = ($GIFtemp ? 'ImageCreateFromGIF' : 'ImageCreateFromPNG');
}
 
Old 09-29-2006, 12:57 PM   #3
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Quote:
You can't have an if() statement with a semicolon after it.
i dont know PHP, but this must be PHP-specific, no?
 
Old 09-29-2006, 01:10 PM   #4
MOS JEFF-INITELY
Member
 
Registered: Sep 2006
Distribution: Windows .. MUAHAHAHA
Posts: 66

Rep: Reputation: 15
yes, Perl/PHP (PHP is a subset of Perl)

in other languages you can run one statement without using {} however in Perl/PHP this is not allowed you need the {} or you will get an error

Last edited by MOS JEFF-INITELY; 09-29-2006 at 01:12 PM.
 
Old 09-29-2006, 01:13 PM   #5
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
It's valid php. For instance, this works:

Code:
if(true);
However, you cannot assign an if statment to a variable. Why do you have that random if there? If your trying to assign the result of an equality, just do
Code:
$GIFtemp = $this->getimagesizeinfo[2] == 1
 
Old 09-29-2006, 01:18 PM   #6
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
Quote:
Originally Posted by MOS JEFF-INITELY
yes, Perl/PHP (PHP is a subset of Perl)

in other languages you can run one statement without using {} however in Perl/PHP this is not allowed you need the {} or you will get an error
No, the {} is not needed. PHP is meant to be easy to use... it's very hard to write code that doesn't work in php. I wouldn't compare php and perl either, they're very different. I think people just think of perl when they see php because of the dollar signs.
 
Old 09-29-2006, 01:20 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I_grok is right:
Code:
  // Permissible (but weird) in C/C++, but it's a parse error in PHP
  $GIFtemp = if ($this->getimagesizeinfo[2] == 1);  // Set $GIFtemp to TRUE or FALSE
  $ImageCreateFunction = 
    ($GIFtemp ? 'ImageCreateFromGIF' : 'ImageCreateFromPNG');
Code:
  // Correct in PHP ... clearer in any language
  if ($this->getimagesizeinfo[2] == 1) {
    $ImageCreateFunction = 'ImageCreateFromGIF';
  }
  else {
    $ImageCreateFunction = 'ImageCreateFromPNG';
  }
This link might help explain these kinds of PHP error messages a bit better:

http://www.devarticles.com/c/a/PHP/M...-PHP-Errors/1/

'Hope that helps .. PSM

Last edited by paulsm4; 09-29-2006 at 01:22 PM.
 
Old 09-29-2006, 01:42 PM   #8
MOS JEFF-INITELY
Member
 
Registered: Sep 2006
Distribution: Windows .. MUAHAHAHA
Posts: 66

Rep: Reputation: 15
Quote:
Originally Posted by 95se
I wouldn't compare php and perl either, they're very different. I think people just think of perl when they see php because of the dollar signs.
not true, I'm a Perl person myself havent used PHP much, but I do know that PHP syntax is based on Perl and a bit of C.

The major differences PHP is made directly for web page scripting where as Perl script is used more generically and not only for web pages.

Although there are obvious differences, Perl has web extensions in CPAN that make PHP and Perl scripts very similar.
 
Old 09-29-2006, 02:40 PM   #9
jason1074
LQ Newbie
 
Registered: Sep 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you everyone for trying to help me. I tried to fix the code myself but I kept getting other parse errors. I'm a total dummy with these codes.

The error was on line 1043 after fixing the code according to everyones input I started getting an error on line 1700.

Would anyone like to check it out and let me know what I need to do? I really appreciate all the help.

Jay
 
Old 09-29-2006, 02:43 PM   #10
jason1074
LQ Newbie
 
Registered: Sep 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Here's the next erro:

Parse error: syntax error, unexpected ':' in /home/shoutout/public_html/thumb/class.php on line 1700

Line 1700:
$dither = (0 < strlen ($dither) ? : true);
 
Old 09-29-2006, 03:01 PM   #11
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Please look back at my previous link - it's the same problem:
http://www.linuxquestions.org/questi...80#post2443080

1. As far as the real problem:
You do NOT want to create boolean expressions like "$dither = (0 < strlen ($dither) ? : true);" if you can do the same thing with a conditional like "if (strlen ($dither) > 0) {...}"

2. As far as whether or not you need "{}":
No, you don't.

The problem isn't braces, the problem is trying to use a boolean expression instead of just using a simple "if/then/else".

3. As far as the relationship between Perl and PHP:
The answer is ultimately a matter of taste. Sure, they're both "C-like". And sure, they're both scripting languages.

But they were written by different people, for different purposes, run in different environments, and have different strengths and weaknesses.

Personally, I think the two are more dissimilar than not.

'Hope that helps .. PSM

Last edited by paulsm4; 09-29-2006 at 03:08 PM.
 
Old 09-30-2006, 10:49 AM   #12
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Quote:
PHP is a subset of Perl
Eh??

I don't think so man. Except for trivial syntax similarities they are completely unrelated.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the meaning of "PHP Parse error: parse error, unexpected $ in..." frandalla Programming 23 03-04-2009 12:34 PM
meaning of numerical error happy78 Linux - General 1 02-17-2006 04:48 PM
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 01:29 AM
error message's meaning, Please help foxele Programming 3 11-14-2004 11:50 PM
error message meaning? Michele Linux - Newbie 2 08-12-2003 09:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration