tlavelle Posted August 15, 2007 Share Posted August 15, 2007 Can someone help with this? <?php //initialize session session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $year_query = "SELECT distinct year FROM userdata"; $industry_query = "SELECT distinct comp_desc FROM comp_desc"; $metric_query = "SELECT metric_desc.met_desc, userdata.median, userdata.best_pract FROM metric_desc, userdata where metric_desc.met_key=userdata.met_key and $useryear=userdata.year"; // execute query $year_result = mysql_query($year_query) or die ("Error in query: $query. ".mysql_error()); $industry_result = mysql_query($industry_query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($year_result) > 0 or mysql_num_rows($industry_result)){ // yes // print them one after another if (!isset($_POST['wercbench1'])) { /*echo"<form method=\"POST\" action=\"<?php$_SERVER['PHP_SELF']; ?>\" name=\"wercbench1\">";*/ echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench1\">"; echo"<table style=\"width: 100%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; echo"<tbody>"; echo" <tr>"; echo" <td>Select the comparison year and group then click next"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"year\">"; while($row = mysql_fetch_row($year_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"industry\">"; while($row = mysql_fetch_row($industry_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo"</td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench1_next\"></button></td>"; echo" <td></td>"; echo" </tr>"; echo"</tbody>"; echo"</table>"; echo"</form>"; } } elseif(!isset($_POST['wercbench2']) and (mysql_num_rows($metric_result) > 0){ // yes // print them one after another echo "<form action=\"<?php echo $_SERVER['PHP_SELF']; ?>\" method=\"post\" name\"wercbench2\">"; 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=\"submit\" value=\"Compare\"></td></tr></table>"; } else { // no // print status message echo "No rows found!"; } // free result set memory mysql_free_result($metric_result); } else { // no // print status message echo "No rows found!"; } // free result set memory mysql_free_result($year_result); mysql_free_result($industry_result); // close connection mysql_close($connection); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/ Share on other sites More sharing options...
uwannadonkey Posted August 15, 2007 Share Posted August 15, 2007 else { // no // print status message echo "No rows found!"; } // free result set memory mysql_free_result($metric_result); } thats extra^ echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Compare\"></td></tr></table>"; } ^extra also. i may be wrong, but im counting your open and closes.. Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324835 Share on other sites More sharing options...
SirChick Posted August 15, 2007 Share Posted August 15, 2007 // free result set memory mysql_free_result($metric_result); } remove that } ^ damn uwannadonkey beat me to it. but i would like a donkey Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324838 Share on other sites More sharing options...
uwannadonkey Posted August 15, 2007 Share Posted August 15, 2007 hey. no problem, we just here to help right? and no donkeys for you. Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324840 Share on other sites More sharing options...
tlavelle Posted August 15, 2007 Author Share Posted August 15, 2007 Thanks guys. Just a total n00bie question. IS there a good way to keep track of teh opens and closes? I am using folding and notepad++ and I still am getting glossy eyed Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324867 Share on other sites More sharing options...
wildteen88 Posted August 15, 2007 Share Posted August 15, 2007 I prefer to place opening and closing braces on separate lines, eg: if(bla) { if(blah bla) { more codee } code here } That will make sure code more readable, cleaner and easier to match braces. Some editors have built in brace matching, which means when you're in a code block (code between { and }) it'll highlight the matching braces for that code block. I'm sure Notepad++ has this feature. Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324869 Share on other sites More sharing options...
tlavelle Posted August 15, 2007 Author Share Posted August 15, 2007 Guys, I am sorry but I still am getting: Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\bench2\index2.php on line 82 I have counted all my openings and closings and am just not seeing the issue <?php //initialize session session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $year_query = "SELECT distinct year FROM userdata"; $industry_query = "SELECT distinct comp_desc FROM comp_desc"; $metric_query = "SELECT metric_desc.met_desc, userdata.median, userdata.best_pract FROM metric_desc, userdata where metric_desc.met_key=userdata.met_key and $useryear=userdata.year"; // execute query $year_result = mysql_query($year_query) or die ("Error in query: $query. ".mysql_error()); $industry_result = mysql_query($industry_query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($year_result) > 0 or mysql_num_rows($industry_result)){ // yes // print them one after another if (!isset($_POST['wercbench1'])) { /*echo"<form method=\"POST\" action=\"<?php$_SERVER['PHP_SELF']; ?>\" name=\"wercbench1\">";*/ echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench1\">"; echo"<table style=\"width: 100%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; echo"<tbody>"; echo" <tr>"; echo" <td>Select the comparison year and group then click next"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"year\">"; while($row = mysql_fetch_row($year_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"industry\">"; while($row = mysql_fetch_row($industry_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo"</td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench1_next\"></button></td>"; echo" <td></td>"; echo" </tr>"; echo"</tbody>"; echo"</table>"; echo"</form>"; } } elseif(!isset($_POST['wercbench2']) and (mysql_num_rows($metric_result) > 0){ // yes // print them one after another echo "<form action=\"<?php echo $_SERVER['PHP_SELF']; ?>\" method=\"post\" name\"wercbench2\">"; 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=\"submit\" value=\"Compare\"></td></tr></table>"; } else { // no // print status message echo "No rows found!"; } // free result set memory mysql_free_result($year_result); mysql_free_result($industry_result); mysql_free_result($metric_result); // close connection mysql_close($connection); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324875 Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 elseif(!isset($_POST['wercbench2']) and (mysql_num_rows($metric_result) > 0){ should be elseif(!isset($_POST['wercbench2']) and (mysql_num_rows($metric_result) > 0)){ You forgot to close the elseif Quote Link to comment https://forums.phpfreaks.com/topic/65088-parse-error-syntax-error-unexpected-in-cxampphtdocsbench2index2php-o/#findComment-324880 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.