?
Solved

Syntax on if statement

Posted on 2014-07-23
6
Medium Priority
?
110 Views
Last Modified: 2014-08-13
What is wrong with the line that has $ROW[NOR]
I know it's syntax.

if ("$Up_Down" == "U")
                        (
                        if ("{$ROW['NOR']}" > $North_Grid)
                              {
                                    continue;
                              }
0
Comment
Question by:breeze351
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40215179
When you put quotes around the variables, they become text and not variables.  Try this...
if ($Up_Down == "U")
                        (
                        if ($ROW['NOR'] > $North_Grid)
                              {
                                    continue;
                              } 

Open in new window

And is it 'ROW' or 'row'?  Remember that PHP variable names are case sensitive.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40215457
PHP variable names are case sensitive.
And so are array indexes in associative arrays.  And so are property names in objects.

This article tells how to use quote marks in PHP.  Executive summary: Fewer quote marks are almost always better.  If you still have any questions after reading the article, please post back and we'll be glad to clarify.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12241-Quotation-Marks-in-PHP.html
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40215467
And now that I look at the code in my text editor I see that the character on line 2 is an open-paren, not a curly brace.  Curly braces are used for control structures in PHP.  Try it a bit more like this (at least this will parse correctly).  In this code snippet, line #5 is the same as line 2 in the original question.  ( != {

<?php // demo/temp_breeze351.php
error_reporting(E_ALL);

if ("$Up_Down" == "U")
{
    if ($ROW['NOR'] > $North_Grid)
    {
        continue;
    } 
}

Open in new window

0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 17

Accepted Solution

by:
Chris Harte earned 2000 total points
ID: 40216337
Strange looking code. Braces inside double quotes stops the variable being parsed. If that is what you want, and I cannot imagine why it would be,  then this may be the correct code. As Ray mentioned, parenthesis are not braces

if ($Up_Down == "U")
{
    if ('$ROW["NOR"]' > $North_Grid)
    {
        continue;
    }
}

Open in new window

0
 
LVL 7

Expert Comment

by:Vimal DM
ID: 40219033
Hi,

I have tried the below code based on my local box, it is working fine,

$ROW['NOR'] = 12;
$North_Grid = 10;
$Up_Down = 'U';

if ("$Up_Down" == "U"){
if ("{$ROW['NOR']}" > $North_Grid) {
                  echo 'Test';
        }
}
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40219198
@vimalmaria: Yes, the parse error is caused by using parenthesis instead of curly braces.  PHP often reports these kinds of parse errors on the line that triggered the error in the parser, which may not be the same line number as the line that contained the wrong character.
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question