-4

I have a strange error message after using the post to wall function. It did successfully post to the wall however i got a very weird strange error.

[Mon Dec 28 12:47:36 2015] [error] [client 5.29.224.120] PHP Notice: Use of undefined constant female - assumed 'female' in /datas/vhosts/nf.com/httpdocs/agence1948/result.php on line 178, referer: https://nf.com/agence1948/question.php [Mon Dec 28 12:47:36 2015] [error] [client 5.29.224.120] PHP Notice: Use of undefined constant male - assumed 'male' in /datas/vhosts/nf.com/httpdocs/agence1948/result.php on line 182, referer: https://nf.com/agence1948/question.php

I use this code

<?php if($_SESSION['score'] >= 15 && $_SESSION['score'] <= 20): ?>
  
  <?php if($_SESSION['gender'] == female): ?>
   <img src="img/Refaeli.jpeg"/>
  <?php endif; ?>
  
  <?php if($_SESSION['gender'] == male): ?>
   <img src="img/avidan.jpg"/>
  <?php endif; ?>
  

someone knows whats is the problem?

thank you

user5723248
  • 17
  • 1
  • 3

3 Answers3

4

male and female are strings, so enclose with quotations!

It should be:

<?php if($_SESSION['gender'] == 'female'): ?>
            <img src="img/Refaeli.jpeg"/>
        <?php endif; ?>

        <?php if($_SESSION['gender'] == 'male'): ?>
            <img src="img/avidan.jpg"/>
        <?php endif; ?>
Thamilhan
  • 13,040
  • 5
  • 37
  • 59
1

male and female should be enclosed with quotes as they are strings. E.g

<?php if($_SESSION['gender'] == 'female'): ?> OR

<?php if($_SESSION['gender'] == 'male'): ?>
William Madede
  • 727
  • 4
  • 8
1

Two error in your code

1) You need to end first if condition

2) male and female inside quotes for comparision .Otherwise it is treated as constant

<?php if ($_SESSION['score'] >= 15 && $_SESSION['score'] <= 20): ?>

    <?php if ($_SESSION['gender'] == "female"): ?>// use quotes
        <img src="img/Refaeli.jpeg"/>
    <?php endif; ?>

    <?php if ($_SESSION['gender'] == "male"): ?>// use quotes
        <img src="img/avidan.jpg"/>
    <?php endif; ?>
<?php endif; ?>// end first condition
Saty
  • 22,443
  • 7
  • 33
  • 51