Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:37:28+00:00 2026-05-26T10:37:28+00:00

A new problem has arisen for me as I tried to run my script

  • 0

A new problem has arisen for me as I tried to run my script on a different PHP Server.

ON my old server the following code appears to work fine – even when no s parameter is declared.

<?php
 if ($_GET['s'] == 'jwshxnsyllabus')
echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/jwshxnporsyllabus.xml',         '../bibliographies/jwshxnbibliography_')\">";
if ($_GET['s'] == 'aquinas')
echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/AquinasSyllabus.xml')\">"; 
 if ($_GET['s'] == 'POP2')
echo "<body onload=\"loadSyllabi('POP2')\">";
elseif ($_GET['s'] == null)
echo "<body>"
?>

But now, on a my local server on my local machine (XAMPP – Apache) I get the following error when no value for s is defined.

Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 43
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 45
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 47
Notice: Undefined index: s in C:\xampp\htdocs\teaching\index.php on line 49

What I want to happen for the script to call certain javascript functions if a value is declared for s, but if nothing is declared i would like the page to load normally.

Can you help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:37:28+00:00Added an answer on May 26, 2026 at 10:37 am

    Error reporting will have not included notices on the previous server which is why you haven’t seen the errors.

    You should be checking whether the index s actually exists in the $_GET array before attempting to use it.

    Something like this would be suffice:

    if (isset($_GET['s'])) {
        if ($_GET['s'] == 'jwshxnsyllabus')
            echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/jwshxnporsyllabus.xml',         '../bibliographies/jwshxnbibliography_')\">";
        else if ($_GET['s'] == 'aquinas')
            echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/AquinasSyllabus.xml')\">"; 
        else if ($_GET['s'] == 'POP2')
            echo "<body onload=\"loadSyllabi('POP2')\">";
    } else {
        echo "<body>";
    }
    

    It may be beneficial (if you plan on adding more cases) to use a switch statement to make your code more readable.

    switch ((isset($_GET['s']) ? $_GET['s'] : '')) {
        case 'jwshxnsyllabus':
            echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/jwshxnporsyllabus.xml',         '../bibliographies/jwshxnbibliography_')\">";
            break;
        case 'aquinas':
            echo "<body onload=\"loadSyllabi('syllabus', '../syllabi/AquinasSyllabus.xml')\">";
            break;
        case 'POP2':
            echo "<body onload=\"loadSyllabi('POP2')\">";
            break;
        default:
            echo "<body>";
            break;
    }
    

    EDIT: BTW, the first set of code I wrote mimics what yours is meant to do in it’s entirety. Is the expected outcome of an unexpected value in ?s= meant to output no <body> tag or was this an oversight? Note that the switch will fix this by always defaulting to <body>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am new in JSP,i have some problem with the following code : <%@
New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) {
Following on from my previous question [link text][1] , I have a new problem.
I'm having this problem on a new cruisecontrol.net install running on Windows Server 2003
A new question has arisen in relation to an earlier question of mine .
My problem has to do with PHP, jQuery and CSS. I want to make
The following problem has been fixed, I added an 's' to the end of
New problem with VS2005 Team Build: Building locally a solution of a mobile client
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.