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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when using If statement

Status
Not open for further replies.

Sanjes

Programmer
Oct 15, 2002
9
GB
When im using an If statement in PHP with the word (keyword) and, OR it gives me an error

eg

IF ($var >1) AND ($var<5)
echo &quot;Between 2 and 4&quot;

Im using IIS on Win2k, im writing my php scripts in Macromedia Homesite 5..

Please could you assist
thank you
 
Try

IF (($var >1) && ($var<5)) ______________________________________________________________________
TANSTAAFL!
 
Parse error: parse error, unexpected T_BOOLEAN_AND in E:\Inetpub\ on line 97

this is the error message if i use the && for &quot;AND&quot; or || for &quot;OR&quot;,

sorry to be a pain
 
You should be using &quot;&&&quot; and &quot;||&quot;. Those operators have higher precedence than &quot;and&quot; and &quot;or&quot;, repectively.

Did you also add the outer set of parentheses? ______________________________________________________________________
TANSTAAFL!
 
i didnt but i have just tried it and it works thanks im have been working on that little thing for about an hour last week... i know very fundamental issue. thank u for ur help

sanj
 
In PHP all conditionals, &quot;if&quot;, &quot;while&quot;, &quot;for&quot;, &quot;switch&quot; require that the condition be withing parentheses.

This is different from, say VB, where such things are optional. ______________________________________________________________________
TANSTAAFL!
 
yea i think that is where i was failing, i have done VB before but this is the first time im doing a true web scripting language (even though VB can do web scripting not very widely used)

I very quick question, the debate on that mySQL cannot do correlated sub queries, i.e. queries within queries... how far can it nest queries, for example can u do sub queries upto a certain point like Select (......
Select (......
Select(.......)))
thank u in advance
sanj
 
This from the MySQL online manual (
MySQL Server currently only supports nested queries of the form INSERT ... SELECT ... and REPLACE ... SELECT .... You can, however, use the function IN() in other contexts. Subselects are currently being implemented in the 4.1 development tree. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top