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
Having Error: "Undefined index"
Moderator: General Moderators
-
wallstreet
- Forum Newbie
- Posts: 6
- Joined: Tue May 29, 2007 8:07 am
Code: Select all
<?php
$arr = array(
'index1'=>'val1',
'index3'=>'val3'
);
echo $arr['index1']; // <- ok, index1 exists in $arr
echo $arr['indexXYZ']; // <- notice: undefined index indexXYZWhat's on line 4 in photos-view.php ?
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
-
wallstreet
- Forum Newbie
- Posts: 6
- Joined: Tue May 29, 2007 8:07 am
Here is the entire photos-view.php page (Hebrew text translated to english):
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!
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>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!
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
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>- Gente
- Forum Contributor
- Posts: 252
- Joined: Wed Jun 13, 2007 9:43 am
- Location: Ukraine, Kharkov
- Contact:
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
or this one
Use following code as example
Code: Select all
if (isset($_GET['view']))
{
$view = '';
}
else
{
$view = $_GET['view'];
}Code: Select all
$view = (isset($_GET['view'])) ? $_GET['view'] : '';