0

Hello
I get this message : Notice: Undefined index: id in *****7index.php on line 26 when we go from php4 to php5.

My code on line 25-35 is :

<?php 
 if($_GET["id"] == "web"){
  echo "<link rel='stylesheet' href='css/style.css' media='screen'/>";
	echo "<link rel='stylesheet' href='css/style.css' media='handheld, only screen and (max-device-width:480px)' />";
	echo "<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />";
 } else {
  echo "<link rel='stylesheet' href='css/style.css' media='screen'/>";
	echo "<link rel='stylesheet' href='css/iphone.css' media='handheld, only screen and (max-device-width:480px)' />";
	echo "<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />";
 }
?>

Please help me !!

Espen

Edited by __avd: Added [code] tags.

5
Contributors
9
Replies
24
Views
6 Years
Discussion Span
Last Post by Espenij
0

It is a notice. Your code will not break on it. The reason you are getting this is because the 'id' may not have been set in the GET array. You can resolve it like this:

$my_id = isset($_GET['id']) ? $_GET['id'] : '';

It checks if the value is set, otherwise it will return an empty string.

0

Hi
Thank-you, but where do I put this line ? Under or before line 26 ?


Espen

0

You could put it before it, and replace $_GET["id"] on the line with $my_id (but please, name it something more useful :)). But personally I would never do this, it needlessly consumes memory and CPU cycles. It's a notice, don't worry about it.

0

Try this

<?php 
 if(isset($_GET["id"])){
	if($_GET["id"] == "web"){
  echo "<link rel='stylesheet' href='css/style.css' media='screen'/>";
	echo "<link rel='stylesheet' href='css/style.css' media='handheld, only screen and (max-device-width:480px)' />";
	echo "<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />";
 } else {
  echo "<link rel='stylesheet' href='css/style.css' media='screen'/>";
	echo "<link rel='stylesheet' href='css/iphone.css' media='handheld, only screen and (max-device-width:480px)' />";
	echo "<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />";
	}
 }
?>
0
if(isset($_GET["id"]) && $_GET["id"] == "web"){
  echo "<link rel='stylesheet' href='css/style.css' media='screen'/>";
	echo "<link rel='stylesheet' href='css/style.css' media='handheld, only screen and (max-device-width:480px)' />";
	echo "<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />";
 } else {
  echo "<link rel='stylesheet' href='css/style.css' media='screen'/>";
	echo "<link rel='stylesheet' href='css/iphone.css' media='handheld, only screen and (max-device-width:480px)' />";
	echo "<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />";
 }
0

Thanks, but i got one more :

<?php
 $_SESSION["referer"] .= $_SERVER['HTTP_REFERER'];
 $hejsa = $_SESSION["referer"]
 ?>
<div id="sub_nav">
	  <ul>
		<?php
		 echo "<li><a href='http://www.bbf.no/sok-lan2.php?$hejsa' title='Forbrukslån uten sikkerhet' id='forside_link'>Søk forbrukslån</a></li>";
		?>
		
		
			 <li><a href="laanekalkulator.php" title='Lånekalkulator'>Lånekalkulator</a></li>
			 <li><a href="priser-forbrukslaan" title='Priser forbrukslån'>Priser forbrukslån</a></li>
	 </ul>
	</div>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

Sorry to bother, but this one is also wrong. My problem is that i dont handle php5.

<?php 
			 $antalmnd = $_POST["tid"];
			 $laan = $_POST["laan"];
			
			 
			 if($antalmnd == "" || $laan = ""){
			 
			 } else {
			 
			 $overst = 0.119/12;
			 $nederst = 1-(pow(1+$overst, $antalmnd));
			 
			 $resultat = ($overst/$nederst)*($_POST["laan"]+990);
			
			 $etab_rente = 990/$_POST["laan"];

PLEASE HELP ME !

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

use [ CODE ] tags. Reading code as normal text is really annoying.

Have a little think about what you're doing before you post too. You've posted for 3 questions so far. We're here to help, but we're not doormats. Help yourself first - your problems are not really big problems. You've added something you shouldn't have in the first example and left out something in the last one.

PLEASE HELP ME !

No need for this.

Edited by diafol: n/a

0

Hello
Sorry, but i fixed it. Was a little desperate. But it is fixed. sorry.

Mvh
Espen

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.