Warning/Error messages at run time
Posted by: Ares (---.freedom2surf.net)
Date: December 31, 2011 03:56PM

I have WAMP set up on two different computers (laptop running Windows 7 and PC running Windows XP).

I can run PHP code on the PC with no warning messages but the same code on the laptop gives messages such as:


Notice: Undefined index: submita in C:\wamp\www\trials\FormTest.php on line 9

Notice: Undefined index: aa in C:\wamp\www\trials\FormTest.php on line 19

Notice: Undefined index: ab in C:\wamp\www\trials\FormTest.php on line 20


the code seems to produce the same results in each case.

Is there some setting that toggles display/suppress of these messages?

The code executed is:

<?php session_start(); # start session

?>

<html><head><title>Form Test input</title></head>
<body>
<?php $self= $_SERVER['PHP_SELF'];

$submita= $_POST['submita'];
if ($submita){

$aa= $_POST['aa'];
$ab= $_POST['ab'];
$_SESSION['aa']=$aa;
$_SESSION['ab']=$ab;

} else {

$aa=$_SESSION['aa'];
$ab=$_SESSION['ab'];

}

# form a
$forma="<form action=\"$self\" method=\"post\">";
$forma.="aa: <input type=\"text\" name=\"aa\" size=\"3\" value=\"$aa\"> ";
$forma.="ab: <input type=\"text\" name=\"ab\" size=\"3\" value=\"$ab\"> ";
$forma.="<input type=\"submit\" name=\"submita\" value=\"Submit a\"><br> </form>";

$msga=$forma;

echo ($msga);
?>
</body></html>

Options: ReplyQuote
Re: Warning/Error messages at run time
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: January 01, 2012 08:56AM

Yes but u should fix the code-
u should not have a variable that is not set

Use. Isset() and empty() to check first


But in the php.ini you can suppress notice warnings by adding

~ E_NOTICE

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Warning/Error messages at run time
Posted by: Ares (---.freedom2surf.net)
Date: January 02, 2012 03:30PM

Thanks. I like to see the warning messages (and can now fix them as you suggest) so I have removed ~E_NOTICE from php.ini in my WAMP installation which was not showing them.

Options: ReplyQuote


Sorry, only registered users may post in this forum.