By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,358 Members | 2,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,358 IT Pros & Developers. It's quick & easy.

Error: Notice: Undefined index: channels in /home/forcefed/public_html/index.php on

P: 14
$channels=$_GET['channels']; if (empty($channels)) { $channels='blank'; } changechannels($channels);
$theatre=$_GET['theatre']; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre);
$info=$_GET['info']; if (empty($info)) { $info='noinfo'; } changeinfo($info);


Hey everyone,

I keep getting an error regarding the above code. These are the errors:

Notice: Undefined index: channels in /home/forcefed/public_html/index.php on line 5
Notice: Undefined index: theatre in /home/forcefed/public_html/index.php on line 6
Notice: Undefined index: info in /home/forcefed/public_html/index.php on line 7


I would assume it has to do with defining my variables in my php script above, but I dont see it cause I suck.

Any help would be appreciated!
Tim
Oct 2 '07 #1
Share this Question
Share on Google+
3 Replies


dafodil
100+
P: 392
When you use $_GET you are getting the value from your other page. Make sure you have a form that has method get.


Here is a sample: http://w3schools.com/php/php_get.asp
Oct 2 '07 #2

P: 14
I see where your coming from, but I am a bit confused. Below is the entire script I am using. The thing is I am not using a form, I am using the get_ command to use switches to incorporate other pages into one, kind of like frames, which is why I am confused, since I never actually use a get_ or form. Am I declaring my variables wrong then? If so, could you recommend anything for me? I read up on w3 a bunch and I understand what they are saying, but I never use a <form and do not have buttons to submit anything, as you can see.

Thanks!


<?php


$channels=$_GET['channels']; if (empty($channels)) { $channels='blank'; } changechannels($channels);
$theatre=$_GET['theatre']; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre);
$info=$_GET['info']; if (empty($info)) { $info='noinfo'; } changeinfo($info);



function changechannels($channels) {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"';
echo '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
echo '<head>';
echo '<title>ForceFedTV Where Local Content Meets The Web</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
echo '<style type="text/css">td img {display: block;}</style>';

echo '<table align="center" border="0" cellpadding="0" cellspacing="0" width="770">';
echo '<tr>';
echo '<td width="130" align="center" valign="top">';
echo '<table align="center" border="0" cellpadding="0" cellspacing="0" width="130">';
echo '<tr>';
echo '<td width="130" align="center" valign="top">';
include ('main.php');
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td width="130" align="center" valign="top">';

switch ($channels)
{
case 'blank':
include ('blank.php'); break;

case 'tv':
include ('/home/forcefed/public_html/tvfiles/tv.php'); break;

case 'movies':
include ('/home/forcefed/public_html/moviefiles/movies.php'); break;

case 'musicvideos':
include ('/home/forcefed/public_html/musicvideofiles/musicvideos.php'); break;

case 'animation':
include ('/home/forcefed/public_html/animationfiles/animation.php'); break;


}}

function changetheatre($theatre) {
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</td>';
echo '<td width="640" align="center" valign="top">';
echo '<table align="center" border="0" cellpadding="0" cellspacing="0" width="640">';
echo '<tr>';
echo '<td width="640" align="center" valign="top">';

switch ($theatre)
{
case 'splash':
include ('splash.php'); break;

case 'movie':
include ('movie.php'); break;

case 'tv':
include ('tv.php'); break;

case 'musicvideos':
include ('musicvideos.php'); break;

case 'animation':
include ('animation.php'); break;

case 'detroit':
include ('detroit.php'); break;

case 'info':
include ('info.php'); break;

case 'bowlingfortrophies':
include ('/home/forcefed/public_html/tvfiles/bowlingfortrophies/bftpilotep1/bftpilotep1.php'); break;

case 'bftpilotep1':
include ('/home/forcefed/public_html/tvfiles/bowlingfortrophies/bftpilotep1/bftpilotep1.php'); break;

case 'bftpilotep2':
include ('/home/forcefed/public_html/tvfiles/bowlingfortrophies/bftpilotep2/bftpilotep2.php'); break;

case 'buriedman':
include ('/home/forcefed/public_html/moviefiles/buriedman/buriedman.php'); break;

case 'selitoya':
include ('/home/forcefed/public_html/moviefiles/selitoya/selitoya.php'); break;

case 'selitoyatrailer':
include ('/home/forcefed/public_html/moviefiles/selitoyatrailer/selitoyatrailer.php'); break;

case 'endcall':
include ('/home/forcefed/public_html/moviefiles/endcall/endcall.php'); break;

case 'thepaperboy':
include ('/home/forcefed/public_html/moviefiles/thepaperboy/thepaperboy.php'); break;

default:
include ('splash.php');
break;
}}



function changeinfo($info) {
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td width="640" align="center" valign="top">';

switch ($info)
{
case 'noinfo':
include ('noinfo.php'); break;

case 'bowlingfortrophies':
include ('/home/forcefed/public_html/tvfiles/bowlingfortrophies/bftinfo.php'); break;

case 'bftpilotep1':
include ('/home/forcefed/public_html/tvfiles/bowlingfortrophies/bftpilotep1/bftpilotep1info.php'); break;

case 'bftpilotep2':
include ('/home/forcefed/public_html/tvfiles/bowlingfortrophies/bftpilotep2/bftpilotep2info.php'); break;

case 'buriedman':
include ('/home/forcefed/public_html/moviefiles/buriedman/buriedmaninfo.php'); break;

case 'selitoya':
include ('/home/forcefed/public_html/moviefiles/selitoya/selitoyainfo.php'); break;

case 'selitoyatrailerinfo':
include ('/home/forcefed/public_html/moviefiles/selitoyatrailer/selitoyatrailerinfo.php'); break;

case 'endcall':
include ('/home/forcefed/public_html/moviefiles/endcall/endcallinfo.php'); break;

case 'thepaperboy':
include ('/home/forcefed/public_html/moviefiles/thepaperboy/thepaperboyinfo.php'); break;

default:
include ('noinfo.php');
break;

}}

echo '</td>';
echo '</tr>';
echo '</table>';
echo '</td>';
echo '</tr>';
echo '</table>';

include ('footer.php');
?>
Oct 2 '07 #3

code green
Expert 100+
P: 1,726
The $_GET[] command is used to read URL variables, normally inside a href string.
I can only see functions and include statements.
Where is the $channels variable that you pass into changechannels coming from? [PHP]$channels=$_GET['channels']; if (empty($channels)) { $channels='blank'; } changechannels($channels);[/PHP]
Oct 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.