473,324 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Undefined Index Error

I wonder if anyone can help resolve an issue I've come across in making a customer's website live when it has tested fine in my own hosting space.

I am getting the following errors: Notice: Undefined index: vartalk

For reference I provide the following links:

My hosting space (where everything appears to be working fine):
http://ridgedale.powweb.com/TinHorse/sbx_intro.php

My customer's hosting space (where the php code is breaking down):
http://www.tinhorse.com/sbx_intro.php

Does anyone have any ideas how I resolve this?

Thanks in advance.
Oct 9 '07 #1
7 1380
Could it be the fact that my hosting space is running on the Debian Linux platform and is running PHP version 4.4.6 and the customer's hosting space is running on the Windows platform and is running PHP version 5.0.4 that this issue has arisen?

Does anyone have any ideas how I might fix this?

Thanks again.
Oct 9 '07 #2
It can't be the version of PHP as I am running version 5.1.6 locally and the files are displaying correctly.

Thanks again.
Oct 9 '07 #3
Atli
5,058 Expert 4TB
Hi.

Could you show us the code that is generating the error?

It is unlikely (yet possible) that your PHP4 code is failing on a PHP5 server. If it were reversed, however, it would be a different story.

There is of course a possibility that your servers are configured differently, but until we see the code it is hard to guess what difference that may be.
Oct 9 '07 #4
I managed to fix the problem that only occurs on a Windows based server by adding an @ symbol in front of each occurence of the $_GET['vartalk'] in the nav.php file which resolved any associated issues with the vartalk variable.

I also noticed once having fixed that issue that the request form was also broken on the Windows platform. It appears that Linux based servers either know how to deal with non-declared variables and Windows based servers don't. Is that a fair summary?

Thanks again.
Oct 9 '07 #5
Sorry, Atli. I missed your reply. Below is the associated code for the nav.php file with that @ symbol inserted which resolved the initial issue:

Expand|Select|Wrap|Line Numbers
  1.    <div id="sbx_nav">
  2.  
  3.                <?php 
  4.  
  5.                $myitem = @$_GET['vartalk'];
  6.  
  7.                if(@$_GET['vartalk'] == "1"): 
  8.                $myitem = '&raquo; Practice Based Innovation';
  9.  
  10.                elseif(@$_GET['vartalk'] == "2"):
  11.                $myitem = '&raquo; Sustainability<br>&nbsp;&nbsp;&nbsp;A Question of Branding';
  12.  
  13.                elseif(@$_GET['vartalk'] == "3"):
  14.                $myitem = '&raquo; Experiential Branding<br>&nbsp;&nbsp;&nbsp;Death of Banality<br><span class="indent2">Birth of Experience</span>';
  15.  
  16.                elseif(@$_GET['vartalk'] == "4"):
  17.                $myitem = '&raquo; Portable Inhalers';
  18.  
  19.                elseif(@$_GET['vartalk'] == "5"):
  20.                $myitem = '&raquo; The Packaging 7f’s';
  21.  
  22.                elseif(@$_GET['vartalk'] == "6"):
  23.                $myitem = '&raquo; US Package Design Magazine<br>&nbsp;&nbsp;&nbsp;Makeover Challenge';
  24.  
  25.                elseif(@$_GET['vartalk'] == "7"):
  26.                $myitem = '&raquo; Innovation<br>&nbsp;&nbsp;&nbsp;Managing Uncertainty';
  27.  
  28.                endif; ?>
  29.  
  30.        <p><a href="sbx_practice.php?vartalk=1">
  31.  
  32.                <?php 
  33.                   if(@$_GET['vartalk'] == "1"): 
  34.                echo $myitem;
  35.                else:
  36.                echo '&nbsp;&nbsp;&nbsp;Practice Based Innovation';               
  37.                endif; ?>
  38.  
  39.                </a></p>
  40.  
  41.        <p><a href="sbx_sustain.php?vartalk=2">
  42.  
  43.                <?php 
  44.                   if(@$_GET['vartalk'] == "2"): 
  45.                echo $myitem;
  46.                else:
  47.                echo '&nbsp;&nbsp;&nbsp;Sustainability<br>&nbsp;&nbsp;&nbsp;A Question of Branding';               
  48.                endif; ?>
  49.  
  50.                </a></p>
  51.  
  52.        <p><a href="sbx_expbrand.php?vartalk=3">
  53.  
  54.                <?php 
  55.                   if(@$_GET['vartalk'] == "3"): 
  56.                echo $myitem;
  57.                else:
  58.                echo '&nbsp;&nbsp;&nbsp;Experiential Branding<br>&nbsp;&nbsp;&nbsp;Death of Banality<br><span class="indent">Birth of Experience</span>';               
  59.                endif; ?>
  60.  
  61.                </a></p>
  62.  
  63.        <p><a href="sbx_inhalers.php?vartalk=4">
  64.  
  65.                <?php 
  66.                   if(@$_GET['vartalk'] == "4"): 
  67.                echo $myitem;
  68.                else:
  69.                echo '&nbsp;&nbsp;&nbsp;Portable Inhalers';               
  70.                endif; ?>
  71.  
  72.                </a></p>
  73.  
  74.        <p><a href="sbx_sevenfs.php?vartalk=5">
  75.  
  76.                <?php 
  77.                   if(@$_GET['vartalk'] == "5"): 
  78.                echo $myitem;
  79.                else:
  80.                echo '&nbsp;&nbsp;&nbsp;The Packaging 7f\'s';               
  81.                endif; ?>
  82.  
  83.                </a></p>
  84.  
  85.        <p><a href="sbx_makeover.php?vartalk=6">
  86.  
  87.                <?php 
  88.                   if(@$_GET['vartalk'] == "6"): 
  89.                echo $myitem;
  90.                else:
  91.                echo '&nbsp;&nbsp;&nbsp;US Package Design Magazine<br>&nbsp;&nbsp;&nbsp;Makeover Challenge';               
  92.                endif; ?>
  93.  
  94.                </a></p>
  95.  
  96.        <p class="lastlink"><a href="sbx_innovation.php?vartalk=7">
  97.  
  98.                <?php 
  99.                   if(@$_GET['vartalk'] == "7"): 
  100.                echo $myitem;
  101.                else:
  102.                echo '&nbsp;&nbsp;&nbsp;Innovation<br>&nbsp;&nbsp;&nbsp;Managing Uncertainty';               
  103.                endif; ?>
  104.  
  105.                </a></p>
  106.  
  107.    </div>
Thanks again.
Oct 9 '07 #6
Atli
5,058 Expert 4TB
Ok, now I see.

The problem has nothing to do with the platform on which your servers are running.

This error is in fact not an error. It is a Warning.
Your code can execute without problems even if you get shown a warning.

The Windows server, which is showing the error has the debug messages turned on, the Linux server apparently does not. So all errors on your Linux server are being suppressed, in order to hide them from your clients.

Adding a @ sign to a function will, in most cases, suppress warnings. This is not advisable however, as this can suppress errors that may help you debug your code. It is better to complete the code without any suppressing errors and disable the debug messages when putting the web on a live server.

The warning you are being shown is shown when you try to access an array element or a variable that does not exists. In your case you are trying to access an element of the $_GET super-global that has not been sent.

To avoid this warning, try formatting you code somewhat like this:
Expand|Select|Wrap|Line Numbers
  1. if(isset($_GET['element'])) {
  2.   $element = $_GET['element'];
  3.   # Input validation would not be a bad idea either!
  4.  
  5.   if($element < 5) {
  6.     echo "Element is less than 5";
  7.   }
  8.   else if($elemet > 5) {
  9.     echo "Element is greater than 5";
  10.   }
  11.   else {
  12.     echo "Element is 5!";
  13.   }
  14. }
  15. else {
  16.   echo "GET variable 'element' was not passed!";
  17. }
  18.  
Oct 9 '07 #7
Atli, thanks for explaining this for me.

Much appreciated.
Oct 11 '07 #8

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

Similar topics

2
by: NotGiven | last post by:
I have display error ON and error reporting to E_ALL. I have a form that opens fine. When you submit it, all the fields that have nothing in them, for example an un-selected radio button, throw...
7
by: Coder Droid | last post by:
I decided to run some code with errors set to E_ALL, just to see what I would run across. It caught a few things, but 90% or better of the messages were of the 'undefined' kind: PHP Notice: ...
9
by: petermichaux | last post by:
Hi, I am curious about how php deals with the following situation where I use an undefined index into an array. PHP seems to be behaving exactly how I want it to but I want to make sure that it...
4
by: John Oliver | last post by:
PHP Notice: Undefined index: name in /home/www/reformcagunlaws.com/new.php on line 6 PHP Notice: Undefined index: address in /home/www/reformcagunlaws.com/new.php on line 7 PHP Notice: ...
3
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined...
3
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice:...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
3
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if...
9
by: simple12 | last post by:
Hello I have a script which have the facility of entering any code to some part of a webpage. I have some problems with it. When i put some code in the script then their is no error shown. When i...
5
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.