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

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.

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


Espen

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.

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;' />";
	}
 }
?>
Member Avatar for diafol
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;' />";
 }

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>

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 !

Member Avatar for diafol

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.

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

Mvh
Espen

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.