Hi I am receiving this message
syntax error, unexpected T_WHILE in C:\wamp\www\Grinding\newpart.php on line 341and another message like syntax error, unexpected T_Varaible..Does T mean something!!
Please,find my code below
thanks for ur help
<?php
//this code will allow user to input the case varaible
//connect to the asma database
$conn=mysql_connect("localhost","asma","halaomar2506"
or die(mysql_error());
mysql_select_db("asma",$conn) or die(mysql_error());
if ($_POST[op] != "view"
{
$get_matgroup="SELECT `material_Group_id` as id, `name`, `mg_index` FROM `material_group` ORDER By `name`";
$get_matgroup_res=mysql_query($get_matgroup)or die(mysql_error());
$get_material="SELECT `material_id`,`name`FROM `material` `name`
order by `name`";
$get_material_res=mysql_query($get_material) or die(mysql_error());
$display_block="<h1>User Input</h1>
<form method=\"POST\" action=\"$_SERVER[PHP_SELF]\">
<P><strong> Material Group</strong>
<select name=\"sel_matgroup\">
<option value=\"\" >..Select One...</option>";
while ($recs=mysql_fetch_array($get_matgroup_res)) {
$id= $recs['id'];
$display_name=$recs['name'];
$display_block .= "<option value=\"$id\">
$display_name</option>";
}
$display_block.= "
</select>
<P><strong>Material</strong><br>
<select name=\"sel_material\">
<option value=\"\" >...Select One... </option>";
while ($recs=mysql_fetch_array($get_material_res)) {
$id=$recs['material_id'];
$display_name=$recs['name'];
$display_block.= "<option value=\"$id\">
$display_name</option>";
}
$display_block.= "
</select>
<P><strong>Hardness</strong><br>
<input type=\"radio\" name=\"hardness\" value=\"<50RC\" ><50RC<br>
<input type=\"radio\" name=\"hardness\" value=\"<50-58RC\" >50-58RC<br>
<input type=\"radio\" name=\"hardness\" value=\">58RC\" >58RC<br>
<P><strong>Sureface Conditions</strong><br>
<input type=\"radio\" name=\"surfce_cond\" value=\"Rough\" >Rough<br>
<input type=\"radio\" name=\"surfce_cond\" value=\"Interupted Cut\" >Interupted Cut<br>
<P><strong>Wheel Selection</strong><br>
<input type=\"radio\" name=\"wheel_sel\" value=\"By System\" checked>By System<br>
<input type=\"radio\" name=\"wheel_sel\" value=\"By User\" >By User<br>
<P><strong>Wheel Selection By User</strong><br>
<P><strong>Abrasive Type</strong><br>
<input type=\"radio\" name=\"abrasive_type\" value=\"Aluminum Oxide\" >Aluminum Oxide
<input type=\"radio\" name=\"abrasive_type\" value=\"Silicon Carbide\" >Silicon Carbide
<input type=\"radio\" name=\"abrasive_type\" value=\"CBN\" >CBN<br>
<P><strong>Bond Type</strong><br>
<input type=\"radio\" name=\"bond_type\" value=\"Vitrified\" >Vitrified
<input type=\"radio\" name=\"bond_type\" value=\"Shellac\">Shellac
<input type=\"radio\" name=\"bond_type\" value=\"Resin\">Resin
<input type=\"radio\" name=\"bond_type\" value=\"Rubber\">Rubber
<input type=\"radio\" name=\"bond_type\" value=\"Metal\">Metal<br>
<P><strong>Grits</strong>
<input type=\"text\" name=\"grits\" size=30><br>
<P><strong>Wheel Diameter</strong>
<input type=\"text\" name=\"w_diameter\" size=30><br>
<P><strong>Speed (mm/s)</strong>
<input type=\"text\" name=\"w_speed\" size=30><br>
<P><strong>Start Diameter (mm)</strong>
<input type=\"text\" name=\"start_diam\" size=30><br>
<P><strong>Finish Diameter (mm)</strong>
<input type=\"text\" name=\"finish_diam\" size=30><br>
<P><strong>Max Roughness Ra(micro meter)</strong>
<input type=\"text\" name=\"roughness\" size=30><br>
<P><strong>Width (mm)</strong>
<input type=\"text\" name=\"width\" size=30><br>
<P><strong>Size Tolerance (micro meter)</strong>
<input type=\"text\" name=\"size_tolerance\" size=30><br>
<p><input type=\"submit\" name=\"submit\" value=\"OK\"></p>
<p><input type=\"submit\" name=\"Cancel\" value=\"Cancel\"></p>
<input type=\"hidden\" name=\"op\" value=\"view\">
</FORM>";
} else if ($_POST[op]=="view"
{
//check for the required fields
if (($_POST[sel_matgroup]== ""
&& ($_POST[sel_material]== ""
&& ($_POST[hardness]== ""
&& ($_POST[roughness]==""
&& ($_POST[width]== ""
) {
header ("Location: newpart.php"
;
exit;
}
//build a select statment to retrieve the related cases accoring to the very important index
//the very important indexes are material group,hardness,wheel bond type,abrasive type and grits
//********************Assign an index of the key features of the cycle specifications*****
//***********************Assign index for material group(primary index) *****
if ($_POST[sel_matgroup]== "Low-C & Alloy Steel"
{
$matgroup_index="LC";
} else if ($_POST[sel_matgroup]== "High-C & Alloy Steel"
{
$matgroup_index="HC";
} else if ($_POST[sel_matgroup]== "Tool Steels"
{
$matgroup_index="TS";
} else if ($_POST[sel_matgroup]== "Cast Iron"
{
$matgroup_index="CI";
} else {
echo "the material is not available";
}
//***********************Assign an index for the hardness (primary index)*****************
if ($_POST[hardness]== "<50RC"
{
$hardness_index="S";
}else if ($_POST[hardness]=="<50-58RC"
{
$hardness_index="M";
}else if ($_POST[hardness]==">58RC"
{
$hardness_index="S";
} else{
echo "Hardness value is not accepted";
}
//*****************************Assign an index for the roughness (primary index*****************
if (($_POST[roughness]>=1.10) && ($_POST[roughness]<= 1.60)){
$roughness_index=1;
} else if (($_POST[roughness]>=0.70)&&($_POST[roughness]<= 0.90)){
$roughness_index=2;
} else if (($_POST[roughness]>=0.40)&&($_POST[roughness]<= 0.50)){
$roughness_index=3;
} else if (($_POST[roughness]>=0.20)&&($_POST[roughness]<= 0.35)){
$roughness_index=4;
} else if (($_POST[roughness]>=0.10)&&($_POST[roughness]<= 0.17)){
$roughness_index=5;
} else{
echo "the roughness value is not accepted";
}
//*************** Assign an index for the wheel(primary index)******************
if ($_POST[wheel_sel]=="By User"
{
// ***** assign an index for the abrasive type********
if ($_POST[abrasive_type]=="Aluminium Oxide"
{
$abrasivetype_index="A";
} else if ($_POST[abrasive_type]=="Silicon Carbide"
{
$abrasivetype_index="B";
}else if ($_POST[abrasive_type]=="CBN"
{
$abrasivetype_index="C";
} else {
$abrasivetype_index=0;
}
// ***************Assign an index for the wheel bond*****
if ($_POST[bond_type]=="Resin"
{
$bondtype_index="B";
}else if ($_POST[bond_type]=="Vitrified"
{
$bondtype_index="V";
} else if ($_POST[bond_type]=="Metal"
{
$bondtype_index="M";
} else if ($_POST[bond_type]=="Rubber"
{
$bondtype_index="R";
} else if ($_POST[bond_type]=="Shellac"
{
$bondtype_index="E";
} else {
$bondtype_index=0;
}
}
//******************* creste the select statment to retrieve similar cases that have the same primary indexes...
// SQL sstatement is created to look for similare cases where the user input of Material Group and Wheel (type,bond,abrasive,gritsaize,grade)
'
//are equal the retrieved cases.
//the primary index (material grindability and wheel) are used to determine a set of applicable cases.
//if there is a mismatch in this category a case is rejected.
if ($_POST[wheel_sel]=="By System"
{
$get_cases= "SELECT *
FROM casesrecord
where matgroup_index= $matgroup_index
and roughness_index= $roughness_index
and hardness_index=$hardness_index";
$get_cases_res= mysql_query ($get_cases) or die (mysql_error());
//We have to make sure that there is at lease one case has got the same primary indexes otherwise the rule based system will be lunched...
//if the SQL statment generated successfully that means there is at least one case
//that met the very important indexes(Material group, grinding type,hardness,wheel type)
if (mysql_num_rows($get_cases_res)<1){
//that means no matced cases. Then the rule base system will be lunced.
echo "the rule based system will be lunched";
}
//The result for matched cases will be temporarly saved into a TempCases table for further calculations
$insert_into_tempcases= "INSERT INTO tempcases values ($get_cases)";
mysql_query($insert_into_tempcases) or die (mysql_error());
// Since, the applicable cases are found and saved now. the important index will be used to choose the nearest case
//from the applicable cases determined by the very important index.
//the important indexes are material, roughness value, work diameter, wheel diameter, and wheel speed.
//the next step, Calculate the similarity value for retrieved cases to select the case with highest similarirty value.
//Calculate Similarity value
$get_matched_cases= "select * from tempcases ";
$get_matched_cases_res= mysql_query($get_matched_cases) or die(mysql_error());
//go throgh each case to calculate the similarity value
while ($result = mysql_fetch_array($get_matched_cases_res)){
$matchedcase=$result[case_id];
$matchedmaterial=$result[material];
$matchedroughness=$result[roughness];
$matchedwork_speed=$result[work_speed];
if ($_POST[sel_material]==$matchedmaterial){
$sim_material=1;
$sim_roughness= 1-(($_POST[roughness]-$matchedroughness)/0.3)*($_POST[roughness]-$matchedroughness)/0.3));
$sim_work_speed=(1-($_POST[work_speed]-$matchedwork_speed)/500)*($_POST[work_speed]-$matchedwork_speed)/500));
$sim= (1+ ($sim_roughness* 0.6)+ ($sim_work_speed*0.4))/2;
$insert_sim= "INSERT INTO tempcases sim value $sim where case_id=$matchedcase";
mysql_query($insert_sim) or die (mysql_error());
}
$sim_roughness= (1-(($_POST[roughness]-$matchedroughness)/0.3)*($_POST[roughness]-$matchedroughness)/0.3));
$sim_work_speed=(1-($_POST[work_speed]-$matchedwork_speed)/500)*($_POST[work_speed]-$matchedwork_speed)/500));
$sim= ($sim_roughness* 0.6)+ ($sim_work_speed*0.4));
$insert_sim= "INSERT INTO tempcases sim value $sim where case_id=$matchedcase";
mysql_query($insert_sim) or die (mysql_error());
}
}
}
if ($_POST[wheel_sel]=="By User"
{
$get_cases="SELECT * FROM casesrecord WHERE matgroup_index= $matgroup_index and hardness_index= $hardness_index and roughness_index= $roughness_index and abrasivetype_index= $abrasivetype_index and bondtype_index= $bondtype_index";
get_cases_res= mysql_query($get_cases) or die (mysql_error());
//we have to make sure that there is at least one matched case...
if (mysql_num_rows($get_cases_res)<1){
//that means no matced cases. Then the rule base system will be lunced.
echo "the rule based system will lunched";
}
//The result for matched cases will be temporarly saved into a TempCases table for further calculations
$insert_into_tempcases= "INSERT INTO tempcases values ($get_cases)";
mysql_query($insert_into_tempcases) or die (mysql_error());
// Since, the applicable cases are found and saved now. the important index will be used to choose the nearest case
//from the applicable cases determined by the very important index.
//the important indexes are material, roughness value, work diameter, wheel diameter, and wheel speed.
//the next step, Calculate the similarity value for retrieved cases to select the case with highest similarirty value.
//Calculate Similarity value
//calculate the similarity value
$get_matched_cases= "select * from tempcases ";
$get_matched_cases_res= mysql_query($get_matched_cases) or die(mysql_error());
//go throgh each case to calculate the similarity value
while ($result = mysql_fetch_array($get_matched_cases_res)){
$matchedcase=$result[case_id];
$matchedmaterial=$result[material];
$matchedroughness=$result[roughness];
$matchedwork_speed=$result[work_speed];
$matchedwheel_speed=$result[wheel_speed];
$matchedwheel_diam=$result[wheel_diameter];
if ($_POST[sel_material]==$matchedmaterial){
$sim_material=1;
$sim_roughness= 1-(($_POST[roughness]-$matchedroughness)/0.3)*($_POST[roughness]-$matchedroughness)/0.3));
$sim_work_speed=(1-($_POST[work_speed]-$matchedwork_speed)/500)*($_POST[work_speed]-$matchedwork_speed)/500));
$sim_wheel_speed=(1-($_POST[wheel_speed]-$matchedwheel_speed)/15)*($_POST[wheel_speed]*$matchedwheel_speed)/15));
$sim_wheel_diam= 1-((($_POST[wheel_diameter]-$matchedwheel_speed)/100)*((($_POST[wheel_diameter]-$matchedwheel_speed)/100));
$sim= (1+ ($sim_roughness* 0.6)+ ($sim_work_speed*0.4)+(0.4*$sim_wheel_speed)+(0.4*$sim_wheel_diam))/2.8;
$insert_sim= "INSERT INTO tempcases sim value $sim where case_id=$matchedcase";
mysql_query($insert_sim) or die (mysql_error());
}
$sim_roughness= (1-(($_POST[roughness]-$matchedroughness)/0.3)*($_POST[roughness]-$matchedroughness)/0.3));
$sim_work_speed=(1-($_POST[work_speed]-$matchedwork_speed)/500)*($_POST[work_speed]-$matchedwork_speed)/500));
$sim= ($sim_roughness* 0.6)+ ($sim_work_speed*0.4)+(0.4*$sim_wheel_speed)+(0.4*$sim_wheel_diam))/1.8;
$insert_sim= "INSERT INTO tempcases sim value $sim where case_id=$matchedcase";
mysql_query($insert_sim) or die (mysql_error());
}
$get_max_sim="SELECT * from tempcases WHERE sim= (Select Max(sim) FROM tempcases)";
$get_max_sim_res= mysql_query($get_max_sim) or die(mysql_error());
'
//since the recommended case is found, in most cases the case retrieved will not exactly
//match the problem definition and must be modified.
//for the same material and roughness group, the wheel,fluid and wheel speed need not to
//be changed.
//the most sensetive parameter for surface roughness is dressing lead.
// modify the feedrate,dressing lead, and workspeed values
While ($modify_result = mysql_fetch_array($get_max_sim_res)) {
$max_caseid=$modify_result[case_id];
$max_feedrate=$modify_result[feed_rate];
$max_workspeed=$modify_result[work_speed];
$max_dressinglead=$modify_result[dressing_lead];
$max_wheelspeed=$modify_result[wheel_speed];
$max_roughness=$modify_result[roughness];
$max_workdiameter=$modify_result[start_diameter];
$max_wheeldiameter=$modify_result[wheel_diameter];
$eqdiameter=(($_POST[start_diam]*$_POST[w_diameter])/($_POST[start_diameter]+$_POST[w_diameter]));
$reco_feedrate= $_POST[feed_rate]*($_POST[start_diameter]*$max_wheeldiameter)/($_POST[w_speed]*$max_wheelspeed);
$reco_dressinglead=(($_POST[dressing_lead]*($max_roughness)*($max_roughness))/($_POST[dressing_lead]*$_POST[dressing_lead);
$max_eqdiam= (($max_workdiameter*$max_wheeldiameter)/($max_workdiameter+$max_wheeldiameter));
$reco_workspeed= ($_POST[w_speed]*($max_eqdiam*$max_wheelspeed)/($eqdiameter*$_POST[w_speed]));
$insert_temp="INSERT INTO tempcases feed_rate,dressing_lead,work_speed VALUES ($reco_feedrate,$reco_dressinglead,$reco_workspeed) WHERE case_id=$max_caseid";
$insert_temp_res= mysql_query($insert_temp) or die(mysql_error());
}
//the recommended case is located and modified..
//to display the result
$get_reco="select * from tempcases";
$get_reco_res= mysql_query($get_reco) or die(mysql_error());
$display_block = "<h1>The Recommended Case</h1>";
while ($res_det=mysql_fetch_array($get_reco_res)){
$caseid=$res_det[case_id];
$partid=$res_det[part_id];
$machine=$res_det[machine_id];
$wheelspeed=$res_det[wheel_speed];
$workspeed=$res_det[work_speed];
$roughness=$res_det[roughness];
$feedrate=$res_det[feed_rate];
$coolant=$res_det[coolant_id];
$materialgroup=$res_det[material_group_id];
$material=$res_det[material_id];
$hardness=$res_det[hardness];
$startdiam=$res_det[start_diameter];
$finishdiam=$res_det[finish_diameter];
$width=$res_det[width];
$wheel=$res_det[wheel_id];
$wheeldiam=$res_det[wheel_diameter];
$eqdiam=$res_det[eq_diameter];
$dresser=$res_det[dresser_id];
$dressingdepth=$res_det[dressing_depth];
$dressinglead=$res_det[dressing_lead];
$display_block .= "<li> the case id $caseid <br>
Part number $partid <br>
Machine $machine <br>
Wheel Speed $wheelspeed <br>
Work Speed $workspeed <br>
Roughness $roughness<br>
Feed Rate $feedrate <br>
Coolant $coolant<br>
Material Group $materialgroup <br>
Material $material<br>
Hardness $hardness<br>
Start Diameter $startdiam<br>
Finish Diameter $finishdiam<br>
Width $width<br>
Wheel $wheel<br>
Wheel Diameter $wheeldiam<br>
Equivelent Diameter $eqdiam<br>
Dresser $dresser <br>
Dressing Depth $dressingdepth <br>
Dressing Lead $dressinglead <br>";
//save if the user happy with the result
//delete the records in the temporary table
}
display_block .= "</u>";
}
}
echo "under contruction";
}
?>
<HTML>
<HEAD>
<TITLE>User Input</TITLE>
</HEAD>
<BODY>
<?php echo "$display_block;" ?>
</BODY>
</HTML>