Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Newbie

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
US
So, I am used to ASP, but was given a little issue to deal with and my attempts didn't quite pan out. I have an includes file for the menu which selects the proper style depending on which tab you are on. So, I am trying to define the section variable at the top of each page and then use it to determine whether or not to mark it as active. Here is the code that I have:

Before the opening HTML tag
Code:
<? php
	$section="QA";
?>

then within the body of the menu.php include file
Code:
<? php if $section="Products" echo "<li id='active'>"; else echo "<li>"; ?>

And that last bit of code gives me this error:
Code:
Parse error: syntax error, unexpected T_IF in /mnt/w0310/d19/s05/b024806b/[URL unfurl="true"]www/canelonesfoods.cn/English/menu.php[/URL] on line 33

Any thoughts?

Willie
 
I suggest that rather than guessing what might work in PHP, you familiarize yourself with the basics. The PHP Online Manual is excellent and will help you much more than we can by correcting each individual line for you. I suggest you start with sections on comparison operators and control structures.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
I agree with Vragabond.
However as a caveat to other readers, I believe that the starting tags for php (unless short tags are turned on) should not include a space
Code:
<?php

If short tags are turned on, php will try to find a constant called
Code:
php

and most probably throw a notice when it can't find one.

 
Additionally and unlike ASP, PHP's syntax requires the parenthesis or round brackets around IF constructs and other functional statements.

Code:
if [red]([/red]$section=="Products"[red])[/red]

You may find this of help:

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ahhh... thanks for the inputs. My biggest question (which I didn't state very well), was if this idea would work with PHP. It looks like it will, I just need to clean up my code a bit/ Again, thank you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top