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>
print($start. "multiplied by"  .$times. "=" .$answer.) ;

The dot after $answer is the problem

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.

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

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

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.

$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

$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++;
}
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.