tlavelle Posted August 24, 2007 Share Posted August 24, 2007 There are 2 if statements at the beginning of this code snippet. The one that is currently commented out works while the one that is not commented out yields this error Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\bench2\index4.php on line 106 I am just not seeing why. Help please? //if((isset($_POST['wercbench2_next']) and ($_POST['year']='2007')) or $_POST['year']='2005'){ if((isset($_POST['wercbench2_next']) and ($_POST['year']='2007')) or (isset($_POST['wercbench1_next']) and ($_POST['year']='2005')) { $useryear=$_POST['year']; $_SESSION['sess_year']=$_POST['year']; $userindustry=$_POST['industry']; $_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; //$metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year and $userindustry=bench_data.comp_key"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); if(isset($_POST['wercbench2_next']) and (mysql_num_rows($metric_result)) > 0){ // yes // print them one after another //echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<form action=\"results.php\" method=\"post\" name\"wercbench3\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Enter your value here</td>"; echo "</tr>"; while($row = mysql_fetch_row($metric_result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>" . $row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td><input type=\"text\" name=\"myvalue[]\" value=\"\" /></td>"; echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"wercbench3\" value=\"Compare\"></td></tr></table>"; } // free result set memory mysql_free_result($year_result); //mysql_free_result($industry_result); mysql_free_result($metric_result); //mysql_free_result($metric_result); } Link to comment https://forums.phpfreaks.com/topic/66512-solved-once-conditional-causes-error-the-other-doesntwhy/ Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 The problem is in the code above it, I believe. You also might want to change the '=' to '==' if you want to compare those two and not set them. Link to comment https://forums.phpfreaks.com/topic/66512-solved-once-conditional-causes-error-the-other-doesntwhy/#findComment-333086 Share on other sites More sharing options...
akitchin Posted August 24, 2007 Share Posted August 24, 2007 count the number of parentheses. you're missing a closing one: //if((isset($_POST['wercbench2_next']) and ($_POST['year']='2007')) or (isset($_POST['wercbench1_next']) and ($_POST['year']='2005')) { // 12 3 2 3 21 2 3 2 3 21 still left with one open parenthesis at the end. EDIT: lemmin is right, you'll need two = signs to compare the two. Link to comment https://forums.phpfreaks.com/topic/66512-solved-once-conditional-causes-error-the-other-doesntwhy/#findComment-333087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.