p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: PHP and MySQL 24-Hour Trainer (http://p2p.wrox.com/forumdisplay.php?f=659)
-   -   Chapter 11 FORMS - Index Error (http://p2p.wrox.com/showthread.php?t=87717)

MRGLENN June 9th, 2012 01:27 PM

Chapter 11 FORMS - Index Error
 
Lesson 11 Forms (Error Message )

When Running: Exercise 11a get

Error Message : Undefined index FtoC on line 8

as well as index CtoF on line 13


Code is:

<?php
require_once("exercise11b.php");
$answer = '';






if ($_POST['FtoC'] ) // Line 8
{
$answer = convertFtoC((float) $_POST['temperature']);
}

elseif ($_POST['CtoF']) // Line 13
{
$answer = convertCtoF((float) $_POST['temperature']);
}



?>

------------------------------------------------------

It Calculates Ok but PHP does Not Understand the

['FtoC'] & ['CtoF'] Index's

It Appears something is Missing (Not Initialized)

(Could Not Find any Info in Book about Debugging this Problem.... )

abeera_000 August 5th, 2012 06:42 AM

Hi :

replace your code with :

<?php
$answer='';
if (isset($_POST['FtoC'])){
$answer=convertFtoC((float) $_POST['temperature']);
} elseif (isset($_POST['CtoF'])) {
$answer=convertCtoF((float) $_POST['temperature']);
}
?>

cheers


All times are GMT -4. The time now is 02:39 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.