Jump to content

Error: Expected ;


newphpcoder

Recommended Posts

Good day! I encountered an error at line 26, error: expected ';'

<?phpinclude 'config.php';$rexist = 0;if($_POST["clt_no"]){   $opname = $_POST["opname"];   $inqty = $_POST["inqty"];   $outqty = $_POST["outqty"];      $totalarr = count($opname) - 1;	for($ctr=0; $ctr < $totalarr; $ctr++)		{		$inqty[$ctr] = (float) $inqty[$ctr];		$outqtyqty[$ctr] = (float) $outqty[$ctr];				 $query = "INSERT INTO clt_traceability (operation_name, input_qty, clt_transact_id) VALUES ('" . $opname[$ctr] . "',  '" . $inqty[$ctr] . "', '" . $outqty[$ctr] . "', '" . $clt_transact_id . "')";		$result = mysql_query($query);		}   			$query = "SELECT * FROM clt_transact WHERE  clt_no = '" . $_POST["clt_no"] . "'";	$result_no = mysql_query($query);		if($result_no)			{			if(mysql_num_rows($result_no) > 0 )			$clicking_input = 0;			$clicking_total = 0;						$query = "SELECT t.input_qty AS clicking_input FROM clt_traceability t, p WHERE t.clt_transact_id = p.clt_transact_id AND t.operation_name '02 Clicking' AND p.clt_no='" . $_POST["clt_no"] . "'";			$resultyield = mysql_query($query);			if($resultyield)				{					if(mysql_num_rows($resultyield) > 0)$clicking_input =mysql_result($resultyield,0,"clicking_input");				}		  /*  $query = "SELECT SUM(t.input_qty) AS clicking_input FROM clt_traceability t, clt_transact p WHERE t.clt_transact_id = p.clt_transact_id AND t.operation_name '02 Clicking' AND p.clt_no='" . $_POST["clt_no"] . "'";			$resultyield = mysql_query($query);			if($resultyield)				{					if(mysql_num_rows($resultyield) > 0)$clicking_input =mysql_result($resultyield,0,"clicking_input");				}*/			$query = "SELECT operation_name FROM clt_traceability t, clt_transact c WHERE t.operation_name = '02 Clicking Total' AND t.clt_transact_id = c.clt_transact_id";			$result = mysql_query($query);			if($result > 0)			{		   			$clicking_total = $clicking_input;			//pano automatic mag eecho o mag aappear ung sum ng inqty sa inqty ng clicking total			}			}	}$rexist = 0;?><html><head>	<style type="text/css">	.myclass {	 font-size: 10pt; font-family:Arial, Helvetica, sans-serif;	}	</style>		<script language="javascript">	function handleEnter(e, nextfield)		{		var characterCode = (e && e.which)? e.which: e.keyCode;		if(characterCode == 13)			{			document.getElementById(nextfield).focus();			return false;			} 		else			{			return true;			}		}	</script></head><body onLoad="document.clttest.clt_no.focus();"><form action='test5.php' method="post" name="clttest"><?php	$rexist = 1;		$query = "SELECT * FROM clt_trace_operations ORDER BY operation_name";	$last_operation_name = "";	$result = mysql_query($query);	if($result)		{		$rexist = 1;				echo "<table>";		echo "<tr><th>Operation</th><th>Inqty</th><th>Outqty</th></tr>";		 $totalrows = mysql_num_rows($result);		$trows = $totalrows - 1;		for($ctr = 0; $ctr < $trows; $ctr++)			{			$row = mysql_fetch_array($result);			$tctr = $ctr + 1;			echo "\n\t<tr>";			echo "\n\t\t<td>";			if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];			$last_operation_name = $row["operation_name"];			echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";   			 echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";			 echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' onkeypress='return handleEnter(event,\"inqty" . $tctr . "\");' /></td>";			echo "\n\t</tr>";			}		if($totalrows > 1);			{			$row = mysql_fetch_array($result);			echo "\n\t<tr>";			echo "\n\t\t<td>";			if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];			$last_operation_name = $row["operation_name"];			echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";   			echo "<input type='hidden' name='opname[]' value='" . $row["operation_name"] . "' /></td>"; 			echo "\n\t\t<td><input size='6' type='text' name='inqty[]' value='$clicking_total' id='inqty"  . $ctr . "' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";			echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' onkeypress='return handleEnter(event,\"saveform" . $ctr . "\");' /></td>";			echo "\n\t</tr>";			}		echo "</table>";		}	   	echo "<p><input type='submit' value='  Save  ' id='saveform' /></p>";	echo "<input type='hidden' name='clt_typeno' value='" . $_POST["clt_typeno"] . "' />";?>

I can't see what is the cuase of that error.Thank you

Link to comment
Share on other sites

Try enclosing the if statement in curly braces.
I'm sorry, I was wrong in putting codes it should be:
<html><head>	<script language="javascript">	function handleEnter(e, nextfield)		{		var characterCode = (e && e.which)? e.which: e.keyCode;		if(characterCode == 13)			{			document.getElementById(nextfield).focus();			return false;			}		else			{			return true;			}		}				// --------------  BEGIN startCalc, Calc, and stopCalc code here -------------function startCalc(){  interval = setInterval("calc()",1);	}function calc(){	var qty = new Array(2);		var qty[0] = parseInt(document.clttype.inqty);	var qty[1] = parseInt(document.clttype.outqty);  //var qty0 = parseInt(document.clttype.inqty[0]); // var qty1 = parseInt(document.clttype.outqty[0]);myqtyval = qty[0]-qty[1];//myqtyval = qty0-qty1;//somedat = "hello" + myqtyval;//document.write(somedat);document.clttype.varqty[0].value = myqtyval;	//document.getElementById("varqty")= myqtyval;//document.getElementById('mytest').value = myqtyval;}function stopCalc(){  clearInterval(interval);}// --------------  END startCalc, Calc, and stopCalc code here -----------------</script>				</head><body onLoad="document.clttype.clt_no.focus();"><?phperror_reporting(0);  //added for testinginclude("config.php");$rexist = 0;if($_POST["clt_no"])	{	$clt_date = $_POST["clt_date"];	$query = "INSERT INTO clt_transact (clt_no, ac2l, b3, cloth_type, roll_no, transact_date, clt_date, pack_setting) VALUES ('" . $_POST["clt_no"] . "', '" . $_POST["ac2l"] . "', '" . $_POST["b3"] . "', '" . $_POST["cloth_type"] . "', '" . $_POST["roll_no"] . "', now(), '" . $clt_date . "', '" . $_POST["pack"] . "')";	$result = mysql_query($query);	$clt_transact_id = mysql_insert_id();		$opname = $_POST["opname"];	$timein = $_POST["timein"];	$timeout = $_POST["timeout"];	$inqty = $_POST["inqty"];	$iun = $_POST["iun"];	$outqty = $_POST["outqty"];	$oun = $_POST["oun"];	$idno = $_POST["idno"];	$mcno = $_POST["mcno"];	$varqty = $_POST["varqty"];	$varsublot = $_POST["varsublot"];	$dateshift = $_POST["dateshift"];	$shift = $_POST["shift"];		$totalarr = count($opname) - 1;	for($ctr=0; $ctr < $totalarr; $ctr++)		{		$inqty[$ctr] = (float) $inqty[$ctr];		$varqty[$ctr] = (float) $varqty[$ctr];		$outqty[$ctr] = (float) $outqty[$ctr];		$query = "INSERT INTO clt_traceability (operation_name, time_in, time_out, input_qty, input_unit, output_qty, output_unit, id_no, mc_no, variance_qty, variance_sublot, date, shift, clt_transact_id) VALUES ('" . $opname[$ctr] . "', '" . $timein[$ctr] . "', '" . $timeout[$ctr] . "', '" . $inqty[$ctr] . "' , '" . $iun[$ctr] . "' ,'" . $outqty[$ctr] . "', '" . $oun[$ctr] . "' , '" . $idno[$ctr] . "', '" . $mcno[$ctr] . "', '" . $varqty[$ctr] . "', '" . $varsublot[$ctr] . "', '" . $dateshift[$ctr] . "', '" . $shift[$ctr] . "', '" . $clt_transact_id . "')";		$result = mysql_query($query);				}   	}$rexist = 0;?><!--<p><a href="clt_definition.php">Clt Types</a>   <a href="clt_query.php">Query</a></p>--><?phpinclude("menu.php");?><form action="clt_main.php" method="post" name="clttype"><?php	$rexist = 1;		echo "Clt No:<input type='text' name='clt_no' onkeypress='return handleEnter(event,\"clt_date\");' />";	echo "<input type='radio' name='pack' id='mother' value='Mother Lot'  /> Mother Lot<br />";   	echo "CLT Date:<input type='text' name='clt_date' onkeypress='return handleEnter(event,\"ac2l\");' />";	echo "<input type='radio' name='pack' id='child' value='Child Lot' /> Child Lot";	  	echo "<table>";	echo "<tr><th class='myclass'>PARTS</th><th class='myclass'>LOT/BATCH #</th></tr>";	echo "<tr><td>AC2L</td><td><input type='text' name='ac2l' id='ac2l' onkeypress='return handleEnter(event,\"b3\");' /></td></tr>";	echo "<tr><td>B3</td><td><input type='text' name='b3' id='b3' onkeypress='return handleEnter(event,\"cloth_type\");' /></td></tr>";	echo "<tr><td>Cloth Type</td><td><input type='text' name='cloth_type' id='cloth_type' onkeypress='return handleEnter(event,\"roll_no\");' /></td></tr>";	echo "<tr><td>Roll No</td><td><input type='text' name='roll_no' id='roll_no' onkeypress='return handleEnter(event,\"timein0\");' /></td></tr>";	echo "</table>";	echo "<p> </p>";		$query = "SELECT * FROM clt_trace_operations ORDER BY operation_name";	$last_operation_name = "";	$result = mysql_query($query);   // if($result)  // Result can be true even if no rows of data are returned.    //	 {					// commented out for testing		$rexist = 1;		echo "<p><center><b>OPERATOR AND MACHINE TRACEABILITY</center></b></p>";		echo "<table>";		echo "<tr><th class='myclass'>OPERATIONS</th><th class='myclass'>Time IN</th><th class='myclass'>Time OUT</th><th class='myclass'>INPUT <br/> QTY</th><th class='myclass'>UNIT</th><th class='myclass'>OUTPUT QTY</th><th class='myclass'>UNIT</th><th class='myclass'>ID #</th><th class='myclass'>MC #</th><th class='myclass'>VARIANCE Qty</th><th class='myclass'>VARIANCE Sub Lot</th><th class='myclass'>DATE</th><th class='myclass'>SHIFT</th></tr>";	  //  $totalrows = mysql_num_rows($result);			$totalrows = 2; //added for testing		$trows = $totalrows - 1;		for($ctr = 0; $ctr < $trows; $ctr++)			{			$row = mysql_fetch_array($result);			$tctr = $ctr + 1;			echo "\n\t<tr>";			echo "\n\t\t<td>";			if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];			$last_operation_name = $row["operation_name"];			echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";   			echo "\n\t<td><input  type='text' name='timein[]' id='timein" . $ctr . "' onkeypress='return handleEnter(event,\"timeout" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='timeout[]' id='timeout" . $ctr . "' onkeypress='return handleEnter(event,\"inqty" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='inqty[]' id='inqty" . $ctr . "' onFocus='startCalc();' onBlur='stopCalc();' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";			echo "\n\t<td>" . $row["input_unit"];			echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>";			echo "\n\t<td><input  type='text' name='outqty[]' id='outqty" . $ctr . "' onFocus='startCalc();' onBlur='stopCalc();' onkeypress='return handleEnter(event,\"idno" . $ctr . "\");' /></td>";			echo "\n\t<td>" . $row["output_unit"];			echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>";			echo "\n\t<td><input  type='text' name='idno[]' id='idno" . $ctr . "' onkeypress='return handleEnter(event,\"mcno" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='mcno[]' id='mcno" . $ctr . "' onkeypress='return handleEnter(event,\"varqty" . $ctr . "\");' /></td>";			echo "\n\t<td><input type='text' name='varqty[]' id='varqty'" . $ctr . "' onkeypress='return handleEnter(event,\"varsublot" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='varsublot[]' id='varsublot" . $ctr . "' onkeypress='return handleEnter(event,\"dateshift" . $ctr . "\");' /></td>";			echo "\n\t<td><input ' type='text' name='dateshift[]' id='dateshift" . $ctr . "' onkeypress='return handleEnter(event,\"shift" . $ctr . "\");' /></td>";		   echo "\n\t<td><input  type='text' name='shift[]' id='shift" . $ctr . "' onkeypress='return handleEnter(event,\"timein" . $tctr . "\");' /></td>";			echo "\n\t</tr>";	//		}  //commented out for testing		if($totalrows > 1);			{			$row = mysql_fetch_array($result);			echo "\n\t<tr>";			echo "\n\t<td >";			if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];			$last_operation_name = $row["operation_name"];			echo "<input type='hidden'  name='opname[]' value='" . $row["operation_name"] . "' /></td>";   			echo "<input type='hidden' name='opname[]' value='" . $row["operation_name"] . "' /></td>";			echo "\n\t<td><input  type='text' name='timein[]' id='timein" . $ctr . "' onkeypress='return handleEnter(event,\"timeout" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='timeout[]' id='timeout" . $ctr . "' onkeypress='return handleEnter(event,\"inqty" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='inqty[]' id='inqty" . $ctr . "' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";			echo "\n\t<td>" . $row["input_unit"];			echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>";			echo "\n\t<td><input  type='text' name='outqty[]' id='outqty" . $ctr . "' onkeypress='return handleEnter(event,\"idno" . $ctr . "\");' /></td>";			echo "\n\t<td>" . $row["output_unit"];			echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>";			echo "\n\t<td><input  type='text' name='idno[]' id='idno" . $ctr . "' onkeypress='return handleEnter(event,\"mcno" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='mcno[]' id='mcno" . $ctr . "' onkeypress='return handleEnter(event,\"varqty" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='varqty[]' id='varqty" . $ctr . "' onkeypress='return handleEnter(event,\"varsublot" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='varsublot[]' id='varsublot" . $ctr . "' onkeypress='return handleEnter(event,\"dateshift" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='dateshift[]' id='dateshift" . $ctr . "' onkeypress='return handleEnter(event,\"shift" . $ctr . "\");' /></td>";			echo "\n\t<td><input  type='text' name='shift[]' id='shift" . $ctr . "' onkeypress='return handleEnter(event,\"saveform\");' /></td>";			echo "\n\t</tr>";			}		echo "</table>";		}	   	echo "<p><input type='submit' value='  Save  ' id='saveform' /></p>";	echo "<input type='hidden' name='clt_typeno' value='" . $_POST["clt_typeno"] . "' />";		?><!-- Mytest: <input type="text" name="mytest" id="mytest"> --></form></body></html>

Link to comment
Share on other sites

Didn't catch anything after a quick glance through the php (also IDE didn't mark anything) so I also looked at the javascript Just grabbing the javascript and my IDE marked this line as a syntax error

var characterCode = (e && e.which)? e.which: e.keyCode;

I have used it as a check before something like (simple)

testvar==1? varY=3: varY=4;

When I run just the javascript and html (removing body onload) up in a browser I get the same error & line 26 you mention. Hope this helps you narrow down your bug search.

Link to comment
Share on other sites

I've been confused because the OP posted two different sets of code, but didn't indicate whether the line with the error is the same in both cases...

Link to comment
Share on other sites

It would help a lot to know WHERE the error is being reported. If it's in the browser window, it's a PHP error. If it's in your console, it's a JavaScript error. A JS error in IE7 will first be reported in the status bar at the bottom of the window, and then you click on that to get a little report.It might also help to know which browser we are discussing.

Link to comment
Share on other sites

Heaven's sake. It's just this:var qty[0] = parseInt(document.clttype.inqty);You can't use the var keyword to declare an element of an array or object. qty has already been declared. Just remove the var keyword.(Why can't the interpreter understand this kind of error more specifically? It seems plain enough . . .)OP: It took us 19 minutes to identify the error once we understood it was a JavaScript error. I suppose we might have done a better job recognizing the text of the message, but really we could have used more help on this. Lesson learned. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...