hello when i run this code, i get this error :

Parse error: syntax error, unexpected T_PRINT in /home/a9017639/public_html/mzrt.php on line 19

<html>
<head>
<link type="text/css" rel="stylesheet" href="xxxx.css">
<Title>xxxxxxxx</Title>
</head>

<body>
<P>
<h1 style="text-align:center;font-size:60px">xxxxxxt</h1>
<BR CLEAR=ALL>
<HR>
<div class="tres">
<?PHP
$zacc=0;
if(isset($_POST['submit'])) {
$animal=$_POST['animals'];

}
?>
<h3> Selected Animal:<? PHP print $animal; ?> </h3>
</div>

can you provide some assistance

Member Avatar for michelleradu

I think you should remove the space between <? and PHP on line 20.

I think you should remove the space between <? and PHP on line 20.

ok thanks :)
i did what you said, but i dont get any value for that statement
the output is like:
Selected Animal:
(no value for $animal)

Member Avatar for michelleradu

ok thanks :)
i did what you said, but i dont get any value for that statement
the output is like:
Selected Animal:
(no value for $animal)

Can you post the code for your html form so I can have a closer look?

Can you post the code for your html form so I can have a closer look?

thank you so much but i think that i solved it.
thanks again :D

Member Avatar for michelleradu

thank you so much but i think that i solved it.
thanks again :D

Happy to help :)

Happy to help :)

oops here it comes again
:(

<html>
<head>
<link type="text/css" rel="stylesheet" href="myzoo.css">
<Title>Feasibility study</Title>
</head>

<body>
<P>
<h1 style="text-align:center;font-size:60px">ReintroWait</h1>
<BR CLEAR=ALL>
<HR>
<div class="tres">
<?PHP
$zacc=0;
if(isset($_POST['submit'])) {
$animal=$_POST['animals'];

}
?>
<h3> Selected Animal:<?PHP echo"$animal"; ?> </h3>
</div>

<FORM name= 'Form2' Method="POST" Action="">
<p style='text-align:center;font-size:30px;'> <u><b> Feasibility study</b></u> <p>
<BR>
<P style='text-align:center;font-size:26px'> Select a suitable environment: <P>
<div class='tress'>
<BR>
<select name='anie'>
<option value=' '> </option>
<option value='Savannah'>Savannah</option>
<option value='Ocean'>Ocean</option>
<option value='Forest'>Forest</option>
<option value='Temperate Rainforest'>Temperate rainforest</option>
<option value='Coral Reef'>Coral reef</option>
<option value='Antarctic'>Antarctic/Arctic</option>
</select>
<BR>
<BR>

<INPUT TYPE='Submit' Name='sub' VALUE='Assess!'>
</div>
<?PHP
if(isset($_POST['sub'])){
$env=$_POST['anie'];
echo"animal";
switch($animal) {

case 'Beluga':

switch($env){
case 'Savannah':
$success=0;
break;
case 'Ocean':
$success=rand(85,100);
break;
case 'Forest':
$success=0;
break;
case 'Temperate Rainforest':
$success=0;
break;
case 'Coral Reef':
$success=rand(25,65);
break;
case 'Antarctic':
$success=rand(45,95);
break;
case ' ' :
echo"<H3> Error! Please select a proper environment <H3> ";
break;
echo"<h3 style='text-align:center'> Your researchers are now carrying out the feasibility study <h3> ";
$fday=rand(30,365);
echo"<h3 style='text-align:center'> Day 1 : Research Started<h3> ";
echo"<h3 style='text-align:center'> Day $fday : Research ended. See below for results! <h3> ";
echo"<BR>";
echo"<BR>";
if($success>=50){
$check="Suitable";}
else {
$check=" Not suitable ";
}
break;
default:
print"Error";
break;
}
}
}


?>
<div class="report">
<H4> Feasibilty Study: Results <h4>
<h4> % Suitability : <?PHP print($success);?> <h4>
<h4> Conclusion:<?PHP print ($check); ?> <h4>

</FORM>
</body>
</html>

i get blank outputs when i run on my web server:
example:
Feasibilty Study: Results
% Suitability :
Conclusion:

when i run it on Easyphp 5.3

Feasibilty Study: Results
% Suitability :
Notice: Undefined variable: success in C:\Users\Tharindu\Desktop\Test\mzrt.php on line 96
Conclusion :
Notice: Undefined variable: check in C:\Users\Tharindu\Desktop\Test\mzrt.php on line 97

Member Avatar for michelleradu

The fact that you are using $success and $check in conditional statements before you have defined them, might be leading to those notices. You should set them to a default
value (0 for example) right before the switch statement starts.

i divided the code into another page

<html>
<head>
<link type="text/css" rel="stylesheet" href="myzoo.css">
<Title>Feasibility study</Title>
</head>

<body>
<FORM name= 'Form2' Method="POST" Action="feasibility.php">
<P>
<h1 style="text-align:center;font-size:60px">ReintroWait</h1>
<BR CLEAR=ALL>
<HR>
<div class="tres">
<?PHP
$zacc=0;
if(isset($_POST['submit'])) {
$animal=$_POST['animals'];

}
echo"
<h3> Selected Animal: $animal</h3>
</div>
";
?>
<div class='tress'>

<p style='text-align:center;font-size:30px;'> <u><b> Feasibility study</b></u> <p>
<BR>
<P style='text-align:center;font-size:26px'> Select a suitable environment: <P>
<div class='tress'>
<BR>
<INPUT TYPE='Text' disabled Value="<?PHP Print($animal); ?>" Name='animal'>
<select name='enviro'>
<option value=' '> </option>
<option value='Savannah'>Savannah</option>
<option value='Ocean'>Ocean</option>
<option value='Forest'>Forest</option>
<option value='Temperate Rainforest'>Temperate rainforest</option>
<option value='Coral Reef'>Coral reef</option>
<option value='Antarctic'>Antarctic/Arctic</option>
</select>
<BR>
<BR>

<INPUT TYPE='Submit' Name='sub' VALUE='Assess!'>
</div>



</FORM>
</body>
</html>

this works
but the next page :

<html>
<head>
<link type="text/css" rel="stylesheet" href="myzoo.css">
<Title>Feasibility study</Title>
</head>

<body>
<FORM name= 'Form3' Method="POST" Action="next.php">
<p style='text-align:center;font-size:30px;'> <u><b> Feasibility study</b></u> <p>
<BR>
<?PHP
$animal=0;
$env=0;
if(isset($_POST['sub'])){
$env=$_POST['enviro'];
$animal=$_POST['animal'];
echo"<h4> $enviro $animal<h4> ";
$success=0;
$check=0;


switch($animal) {

case 'Beluga':

switch($env){
case 'Savannah':
$success=0;
break;
case 'Ocean':
$success=rand(85,100);
break;
case 'Forest':
$success=0;
break;
case 'Temperate Rainforest':
$success=0;
break;
case 'Coral Reef':
$success=rand(25,65);
break;
case 'Antarctic':
$success=rand(45,95);
break;
case ' ' :
echo"<H3> Error! Please select a proper environment <H3> ";
break;
}
echo"<h3 style='text-align:center'> Your researchers are now carrying out the feasibility study <h3> ";
$fday=rand(30,365);
echo"<h3 style='text-align:center'> Day 1 : Research Started<h3> ";
echo"<h3 style='text-align:center'> Day $fday : Research ended. See below for results! <h3> ";
echo"<BR>";
echo"<BR>";
if($success>=50){
$check="Suitable environment";}
else {
$check=" Not suitable ";
}
break;
case ' Asian Elephant':
switch($env){
case 'Savannah':
$success=rand(85,90);
break;
case 'Ocean':
$success=0;
break;
case 'Forest':
$success=rand(90,100);
break;
case 'Temperate Rainforest':
$success=rand(40,60);
break;
case 'Coral Reef':
$success=0;
break;
case 'Antarctic':
$success=0;
break;
case ' ' :
echo"<H3> Error! Please select a proper environment <H3> ";
break;
}
echo"<h3 style='text-align:center'> Your researchers are now carrying out the feasibility study <h3> ";
$fday=rand(30,365);
echo"<h3 style='text-align:center'> Day 1 : Research Started<h3> ";
echo"<h3 style='text-align:center'> Day $fday : Research ended. See below for results! <h3> ";
echo"<BR>";
echo"<BR>";
if($success>=50){
$check="Suitable environment";}
else {
$check=" Not suitable ";
}
break;
case 'White Rhinocerous':
switch($env){
case 'Savannah':
$success=rand(95,100);
break;
case 'Ocean':
$success=0;
break;
case 'Forest':
$success=rand(35,40);
break;
case 'Temperate Rainforest':
$success=rand(10,20);
break;
case 'Coral Reef':
$success=0;
break;
case 'Antarctic':
$success=0;
break;
case ' ' :
echo"<H3> Error! Please select a proper environment <H3> ";
break;
}
echo"<h3 style='text-align:center'> Your researchers are now carrying out the feasibility study <h3> ";
$fday=rand(30,365);
echo"<h3 style='text-align:center'> Day 1 : Research Started<h3> ";
echo"<h3 style='text-align:center'> Day $fday : Research ended. See below for results! <h3> ";
echo"<BR>";
echo"<BR>";
if($success>=50){
$check="Suitable environment";}
else {
$check=" Not suitable ";
}
break;
case 'Western Lowland Gorilla':
switch($env){
case 'Savannah':
$success=rand(10,20);
break;
case 'Ocean':
$success=0;
break;
case 'Forest':
$success=rand(90,100);
break;
case 'Temperate Rainforest':
$success=rand(90,100);
break;
case 'Coral Reef':
$success=0;
break;
case 'Antarctic':
$success=0;
break;
case ' ' :
}
echo"<H3> Error! Please select a proper environment <H3> ";
break;
echo"<h3 style='text-align:center'> Your researchers are now carrying out the feasibility study <h3> ";
$fday=rand(30,365);
echo"<h3 style='text-align:center'> Day 1 : Research Started<h3> ";
echo"<h3 style='text-align:center'> Day $fday : Research ended. See below for results! <h3> ";
echo"<BR>";
echo"<BR>";
if($success>=50){
$check="Suitable environment";
$btn="";
}
else {
$check=" Not suitable ";
$btn='disabled';
}
break;
default:
print"Error";
break;

}

}
echo"
<div class='report'>
<H4> Feasibilty Study: Results <h4>
<h4> % Suitability : $success<h4>
<h4> Conclusion : $check <h4>
</div>";

?>


<INPUT TYPE='Submit'<?PHP print($btn); ?> Name='sub' VALUE='Continue'>
</FORM>
</body>
</html>

i get this error:

Notice: Undefined index: animal in C:\Users\Tharindu\Desktop\Test\feasibility.php on line 16

Notice: Undefined variable: enviro in C:\Users\Tharindu\Desktop\Test\feasibility.php on line 17

Member Avatar for michelleradu
$animal=0;// you dont need this line
$env=0;// you dont need this line
if(isset($_POST['sub']))
{$env=$_POST['enviro'];
$animal=$_POST['animal'];
echo"<h4> $enviro $animal<h4> ";// replace $enviro with $env
$animal=0;// you dont need this line
$env=0;// you dont need this line
if(isset($_POST['sub']))
{$env=$_POST['enviro'];
$animal=$_POST['animal'];
echo"<h4> $enviro $animal<h4> ";// replace $enviro with $env

you are soo awesome!!
however i still get this error(only)
Notice: Undefined index: animal in C:\Users\Tharindu\Desktop\Test\feasibility.php on line 15

Member Avatar for michelleradu

Which of the 2 posted files is feasibility.php?

Which of the 2 posted files is feasibility.php?

the second one (last most)

Member Avatar for michelleradu

If you look carefully at your code, you'll notice you have used

$animal=$_POST['animals'];

in the first file, and then

$animal=$_POST['animal'];

in the second one.
So I think you should have

$animal=$_POST['animals'];

in the second file as well.

i tried what you said yet i still get this error :(

Notice: Undefined index: animals in C:\Users\Tharindu\Desktop\Test\feasibility.php on line 15
Error

i found an answer for sure this time
thank you michelleradu for all your help :D
you rock :D

Member Avatar for michelleradu

i found an answer for sure this time
thank you michelleradu for all your help :D
you rock :D

You're welcome!

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.