/    Sign up×
Community /Pin to ProfileBookmark

PHP if statement with OR operator

Getting an error. Is my syntax correct in the If statement?

[code=php]if (($row[‘sub_sort’] == 1) || ($row[‘sub_sort’] == “”)) {

echo “<a href=’http://www.mdbportfolio.com/”.$page.”.php?client=”.$row[‘client’].”‘ id=’rotator’ style=’margin: 25px auto 0 auto; display:block; width:”.$row[‘width’].”px; height:”.$height.”px; background:url(images/”.$cat.”/”.$row[‘imgName’].”) center center no-repeat’><a/>”;

} else {

echo “<a href=’http://www.mdbportfolio.com/”.$page.”.php?client=”.$row[‘client’].”&subcategory=”.$row[‘subcategory’].”‘ id=’rotator’ style=’margin: 25px auto 0 auto; display:block; width:”.$row[‘width’].”px; height:”.$height.”px; background:url(images/”.$cat.”/”.$row[‘imgName’].”) center center no-repeat’><a/>”;

}[/code]

Thank you in advance!

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@tirnaJun 01.2010 — what's the error message?
Copy linkTweet thisAlerts:
@buildingbrickauthorJun 01.2010 — Parse error: syntax error, unexpected $end in D:Hosting5129084htmlindex.php on line 77
Copy linkTweet thisAlerts:
@buildingbrickauthorJun 01.2010 — which is the end of the coding. But it works fine if I remove the if else statement so the problem must be within this.
Copy linkTweet thisAlerts:
@tirnaJun 01.2010 — Check the apostrophe's in your echo statements.
Copy linkTweet thisAlerts:
@buildingbrickauthorJun 01.2010 — If I remove the if statement it works fine though. Where do you see the error?
Copy linkTweet thisAlerts:
@NogDogJun 01.2010 — There is no parse error in the posted code.

That error message usually indicates that the "{" and "}" braces do not balance out. You may be missing a "}" somewhere, and by commenting out the [b]if[/b] line in question, you are removing a "{" and making the braces balance out -- though incorrectly since you're still probably missing a "}" where you actually need it.
Copy linkTweet thisAlerts:
@buildingbrickauthorJun 01.2010 — Figured it out...I was missing a curly bracket at the end. Thanks for the help though.
×

Success!

Help @buildingbrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...