-1

I'm fairly new to programming. I'm trying to write what should be a fairly basic if, elseif piece of code for my database, but when it compiles it just prints the code from the first if statement all the way to the end. I've been going over it for days and can't work out where I'm going wrong

<!DOCTYPE html>
<html>
<body>

<?php
$row = "A1 Header";
$compulsary = FALSE;
$mutable = TRUE;
$included = FALSE;

if ($compulsary == FALSE and $mutable == TRUE) {
        echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
    }
elseif ($compulsary == FALSE and $mutable == FALSE){    
        echo "'"$row"'";
        }

elseif ($compulsary == True and $mutable == True) {
    echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
    }
else {
    echo "'"$row"'";
    }
?>

</body>
</html>
Dwhite
  • 5
  • 2
  • 2
    If you can see your PHP code... Your server isn't configured to process it properly. How are you calling this file? What is its name? – andrewsi Apr 04 '16 at 13:10
  • 1
    Also, in your code on lines 15 and 22 your not concatenating the strings before echoing them, you should so it should be: `echo "'" . $row . "'";` – C.Liddell Apr 04 '16 at 13:13

3 Answers3

0

try this

<!DOCTYPE html>
<html>
    <body>

        <?php
        $row = "A1 Header";
        $compulsary = FALSE;
        $mutable = TRUE;
        $included = FALSE;

        if ($compulsary == FALSE and $mutable == TRUE) {
            echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
        } elseif ($compulsary == FALSE and $mutable == FALSE) {
            echo "'".$row."'";
        } elseif ($compulsary == True and $mutable == True) {
            echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
        } else {
            echo "'".$row."'";
        }
        ?>

    </body>
</html>
Rakesh Sojitra
  • 3,538
  • 2
  • 17
  • 34
  • Still the same issue, prints out everything from the first Please Enter to the end, with only the second Please Enter being in a text box. – Dwhite Apr 05 '16 at 11:43
0
You can do like this:  



<!DOCTYPE html>
    <html>
    <body>

    <?php
    $row = "A1 Header";
    $compulsary = FALSE;
    $mutable = TRUE;
    $included = FALSE;

    if ($compulsary == FALSE and $mutable == TRUE) {
            echo "<textarea style='background-color:yellow;' name='\"message\"'>Please Enter</textarea><br>";
        }
    elseif ($compulsary == FALSE and $mutable == FALSE){    
            echo $row;
            }

    elseif ($compulsary == TRUE and $mutable == TRUE) {
        echo "<textarea style='background-color:yellow;' name='\"message\"'>Please Enter</textarea><br>";
        }
    else {
        echo $row;
        }
    ?>

    </body>
    </html>
vishu
  • 231
  • 1
  • 9
-2

I think you have a syntax error. Try this:

echo "'\"$row\"'";
Andrei
  • 42,814
  • 35
  • 154
  • 218
cakecoke
  • 7
  • 1