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 10-02-2006, 01:29 PM   #1
jason1074
LQ Newbie
 
Registered: Sep 2006
Posts: 7

Rep: Reputation: 0
Why am I getting this parse error?


Hello,

I am terrible with codes, I am in no way a programmer or developer.
I keep getting this parse error. I posted a message before but thought I would include a link to the complete code, since I didn't understand what or how I was being told to fix the problem.

Error I Receive:
Parse error: syntax error, unexpected T_IF in /home/shoutout/public_html/thumb/class.php on line 1043

Link to a copy of the source code:
http://www.jdelbert.com/class.txt

Is anyone willing to take a look at the code and fix the problem for me? I would really appreciate any help.

Jay
 
Old 10-02-2006, 01:36 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you're not even going to tell us where line 1043 is??
 
Old 10-02-2006, 01:39 PM   #3
jason1074
LQ Newbie
 
Registered: Sep 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Sorry Chris, Here are lines 1042-1049


{
$GIFtemp = if ($this->getimagesizeinfo[2] == 1);
$ImageCreateFunction = ($GIFtemp ? 'ImageCreateFromGIF' : 'ImageCreateFromPNG');
if (ini_get ('safe_mode'))
{
$this->DebugMessage ('ImageMagickThumbnailToGD() aborting because safe_mode is enabled', __FILE__, 852);
return false;
}

Last edited by jason1074; 10-02-2006 at 01:40 PM.
 
Old 10-02-2006, 10:18 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
The if syntax is as follows:
if (condition) statement;
Which means that you have the if keyword followed by the condition in parenthesis. If (and only if) the condition is true will the following statement be executed. There is an extension to the if syntax being:
if (condition) statement1; else statement2;
Where statement1 will be performed if the condition is true and statement2 will be performed if the condition is false.
So the code that you want will be as follows:
PHP Code:
if ($this->getimagesizeinfo[2] == 1)
   
$GIFtemp true;
else
   
$GIFtemp false
An alternative approach (and I suspect the one that you were trying to achieve) is as follows. Because the comparison $this->getimagesizeinfo[2] == 1 will return either true or false this can be assigned directly into the variable $GIFtemp, hence you will have:
PHP Code:
$GIFtemp $this->getimagesizeinfo[2] == 1
(notice in this case there is no need for the if keyword, it is a direct assignment)

Last edited by graemef; 10-02-2006 at 10:33 PM.
 
Old 10-02-2006, 10:25 PM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
I should also add that I don't think that the variable name $GIFtemp is the best thought out name. The variable appears to be used to determine if the image is a gif, maybe $GIFtype would be a better variable name?
 
Old 10-02-2006, 10:25 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, Jason1074 -

This is the same question you asked about the other day:
http://www.linuxquestions.org/questi...d.php?t=488040

The answer's the same, too: use "if/then/else" conditionals instead of terniary (? expressions.

Terniary expressions certainly have their place ... but this isn't it! Just Say No ;-)
 
Old 10-02-2006, 10:52 PM   #7
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
I tend not to use the ternary expression but I think that the following would work:
PHP Code:
$GIFtemp 
$ImageCreateFunction 'ImageCreateFromGIF' 
$ImageCreateFunction 'ImageCreateFromPNG'
Again the problem is because if or ?: doesn't return a value, so the assignment needs to be in the statement.

Last edited by graemef; 10-02-2006 at 10:54 PM.
 
  


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
parse error in QT davidleroux1 Programming 1 12-22-2005 02:41 PM
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 01:29 AM
parse error with bc fisayo Programming 7 08-04-2005 09:23 AM
Parse Error in G++ ashwinipahuja Programming 1 04-29-2004 01:47 AM

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

All times are GMT -5. The time now is 12:10 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