Page 1 of 1
Having Error: "Undefined index"
Posted: Tue Jun 26, 2007 2:58 pm
by wallstreet
Hello,
Only for some users there is the following error:
PHP Notice: index: view in C:/Domains/bars-net.com/wwwroot/iframes/photos-view.php on line 4
Appears on this page:
http://my-caricature.com/bars/photos.php (hebrew page) and some other pages.
What is that error means and how can I solve it?
Thanks!
Eyal
Posted: Tue Jun 26, 2007 3:22 pm
by volka
Code: Select all
<?php
$arr = array(
'index1'=>'val1',
'index3'=>'val3'
);
echo $arr['index1']; // <- ok, index1 exists in $arr
echo $arr['indexXYZ']; // <- notice: undefined index indexXYZ
What's on line 4 in photos-view.php ?
Posted: Tue Jun 26, 2007 3:22 pm
by superdezign
Well, whats the first few lines of code in in that file?
Posted: Wed Jun 27, 2007 5:28 am
by wallstreet
Here is the entire photos-view.php page (Hebrew text translated to english):
Code: Select all
<?
$view=$_GET["view"];
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<body bgcolor=black background="../images/photos/boxbg.jpg">
<?
if ($view=="") {
?><br><br><div dir=rtl><center><font face=verdana size=2 color=white>The view a larger photo here click on the small version of the photo on the right iframe</div><?
} else {
?>
<br><br>
<center>
<img src="../images/photos/m<? echo $view; ?>.jpg" width=281 height=221 style="border: 1px solid #cacaca;">
<br><br>
<center>
<a href="../images/photos/<? echo $view; ?>.jpg" target="Sdf"><font face=verdana size=2 color=white>Enlarge to full screen</a><br><br></a>
<a href="javascript:void(0);" onClick="showme();"><font face=verdana size=2 color=white><div dir=rtl><b>Contact Us!</div></a>
<?
}
?>
<script>
function showme() {
parent.location='../contact.php?text=photo';
}
</script>
This page, which is inside an iframe, is reciving a photos from the iframe on the right via GET method.
The $view var is the name of the ID of the photo.
If there is nothing inside $view, then it's show's a text "please click on some photo".
Thanks!
Posted: Wed Jun 27, 2007 5:48 am
by volka
I see only one access to an array element. But it's on line 2 not 4 as the warning message states.
Anyway, please try
Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<body bgcolor=black background="../images/photos/boxbg.jpg">
<?php
if ( empty($_GET["view"]) ) {
?><br><br><div dir=rtl><center><font face=verdana size=2 color=white>The view a larger photo here click on the small version of the photo on the right iframe</div><?php
} else {
?>
<br><br>
<center>
<img src="../images/photos/m<? echo $_GET['view']; ?>.jpg" width=281 height=221 style="border: 1px solid #cacaca;">
<br><br>
<center>
<a href="../images/photos/<? echo $_GET['view']; ?>.jpg" target="Sdf"><font face=verdana size=2 color=white>Enlarge to full screen</a><br><br></a>
<a href="javascript:void(0);" onClick="showme();"><font face=verdana size=2 color=white><div dir=rtl><b>Contact Us!</div></a>
<?php
}
?>
<script>
function showme() {
parent.location='../contact.php?text=photo';
}
</script>
Posted: Wed Jun 27, 2007 5:48 am
by Gente
If 'view' parameter isn't set in your URL 'undefined index' message will appear every time when you'll try to use $_GET['view'].
Use following code as example
Code: Select all
if (isset($_GET['view']))
{
$view = '';
}
else
{
$view = $_GET['view'];
}
or this one
Code: Select all
$view = (isset($_GET['view'])) ? $_GET['view'] : '';