|| operator not working on '/'

Hi,
I’m trying to get an include to appear only on two pages: /?page_id=11 and the index page
The following code pulls up all pages not just ‘/?page_id=11’ or ‘/’ as the code would suggest.
Using just ‘/?page_id=11’ in the if statement pulls up only that page, but it appears the || operator doesn’t want to play.
Any help to resolve this would be greatly appreciated.

<?php

                        $this_page = $_SERVER['REQUEST_URI'];

                        echo "This page is: " . $this_page;

                        if ($this_page == '/?page_id=11' || '/')
                         {
                                        include 'slider-nivo-script.php';
                                }
                                else {
                                    echo ' - false';
                                }
                         ?>

You’re reading this as

if ($this_page == (‘/?page_id=11’ || ‘/’))

PHP reads it as

if (($this_page == ‘/?page_id=11’) || ‘/’)
The second half of your or doesnt make any logical sense because it has no comparitors, so it evaluates the string into a boolean - which any string that isnt empty evaluates as TRUE.

Sorry, let me correct myself. Any string that isnt empty and is not “0”. Those two are both typeconverted as FALSE. Every other quoted string (once evaluated) is TRUE.

I think what you are trying to do is,


                       if ($_GET['page_id'] == 11) 
                         { 
                                        include 'slider-nivo-script.php'; 
                                } 
                                else { 
                                    echo ' - false'; 
                                } 
 

“/?page_id=11” tells me you are trying to capture a query string.

Thanks Starlion and lorenw,
Starlion, I’m sorry your explanation went right over my head. I’m just a newby with php
lorenw, the code you posted works for me but not when I set permalinks to ‘post name’ in wordpress.
I would also like the ability to include multiple page references in the argument, is this possible?

Use full quotes and $this_page for each OR.

if ($this_page == "/?page_id=11" || $this_page ==  "/")

I’m stuck here! :confused: Can you please help me write code that would only include ‘slider-nivo-script.php’ on pages within the argument controlled by the || operator.

So really the only two conditions are if page_id = 11 or not isset GET page_id.

if (isset($_GET['page_id']) && $_GET['page_id']=="11" || !isset($_GET['page_id']))
{
include 'slider-nivo-script.php';
}

Drummin,
I really appreciate your time, but I have a client on my back to get this fixed and I’m struggling with my minimal knowledge of php, so I have hired a programmer to finish this for me.
I’ll be a guru one day.