0

BELOW IS PHP CODE

GETTING PARSE ERROR AT LINE #16

<html>
<head>
<title>table php file</title>
<?php

  $times=2;
  if(isset($_POST["submit1"]))
 {
 	$start=$_POST["txtStart"];
 	$end=$_POST["txtEnd"];
	$times=$_POST["txtTimes"];
		for($start;$start<=$end;$start++)
			{  $answer= $start * $times;
				print($start. "multiplied by"  .$times. "=" .$answer.) ;
			}
}
?>
</head>
<body>

<form name="form1" method="post" action="table.php" size=15>
Start-Number:<input type="text" name="txtStart"   value="1" size=15>
End-Number:<input type="text" name="txtEnd" value="10">
Answer<input type="text" name="txtTimes" value=<?php print $times; ?>>                    
<P>
<input type="submit" name="submit1" value="Answer">
<P>
</form>

</html>

Edited by rashid47010: n/a

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by ShawnCplus
0

Take a look at the last few characters on line 16, you hae an extra period in there.

Periods are used to join strings, as there is nothing following the final value in the print() statement, you do not need a trailing period.

0

problem solved thank you very much but now I want to print the output line by line BUT IT COMES IN ONE LINE AS A WHOLE

I PUT <br> at the at end of PRINT (LINE#17) BUT GIVES ERROR

PLEASE HAVE A LOOK

but I think <br> is a html tag... here something else which i dont know..

please guide.

Regards,

Rashid

0

problem solved thank you very much but now I want to print the output line by line BUT IT COMES IN ONE LINE AS A WHOLE

I PUT <br> at the at end of PRINT (LINE#17) BUT GIVES ERROR

PLEASE HAVE A LOOK

but I think <br> is a html tag... here something else which i dont know..

please guide.

Regards,

Rashid

0

You can use the newline character in PHP, or you can replace that period you removed and add the tag:

print($start . "multiplied by" . $times . "=" . $answer . "<br />") ;

Providing you keep an eye on your quotes and you make sure you escape them properly, you can add any HTML tak into PHP code within quotes.

Edited by Will Gresham: n/a

0
$TeacherInterrupts = true;
$counter = 1;
while ($counter < 11) {
print(" counter = " + $counter + "<BR>");
if ($TeacherInterrupts = = true) break;
$counter++;
}

Dear concern I want to know the "+$counter+" meaning and

I am also getting the parse error on line #4

please guide me about this

Edited by rashid47010: n/a

0
$TeacherInterrupts = true;
$counter = 1;
while ($counter < 11) {
print(" counter = " + $counter + "<BR>");
if ($TeacherInterrupts = = true) break;
$counter++;
}

Dear concern I want to know the "+$counter+" meaning and

I am also getting the parse error on line #4

please guide me about this

The parse error is because of the +'s, .'s are used for concatenation in PHP (joining strings together)

$TeacherInterrupts = true;
$counter = 1;
while ($counter < 11) {
  print(" counter = " . $counter . "<BR>");
  if ($TeacherInterrupts == true) break;
  $counter++;
}

Edited by ShawnCplus: n/a

This topic has been dead for over six months. 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.