yangkai9999 Posted November 17, 2009 Share Posted November 17, 2009 hello,I am getting Unexpected $end.. whats wrong with my code. And I spent about 2 days to check it out. But I totally lost.<html> <head> <link rel="stylesheet" type="text/css" href="example.css"/> <script type="text/javascript" src="sortable.js"></script> <title>Browse all records from P2</title> </head> <body> <?php $db="mytest"; $link = mysql_connect("localhost","root","Openit4me"); if (! $link) die("Couldn't connect to MySQL"); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); $result = mysql_query( "SELECT * FROM mytest.p1 limit 30" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); mysql_close($link); echo "<P>this is my debug. Each column can be sorted by click column title. </p>"; echo "<P>need add feature to display records page by page when looking a lot of rows</P>"; echo "<P>There are $num_rows records.</P>"; //add titles; echo "<h3><center><font face=arial> My test project II </font></center></h3>" ; echo "<h4><center><font face=arial> Browse all records from table p1 </font></center></h4>"; echo " <table class='sortable' id='mybrowse' align=center height=50 ><tr><th width=10><font face=arial size=2/><div align=center><strong>CHR</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>SNP</strong></div></font></th> <th width=10><font face=arial size=2/><div align=center><strong>minorA</strong></div></font></th> <th width=10><font face=arial size=2/><div align=center><strong>majorA</strong></div></font></th> <th width=20><font face=arial size=2/><div align=center><strong>MAF</strong></div></font></th> <th width=10><font face=arial size=2/><div align=center><strong>NCHROBS</strong></div></font></th> <th width=10><font face=arial size=2/><div align=center><strong>_dom</strong></div></font></th> <th width=10><font face=arial size=2/><div align=center><strong>_rec</strong></div></font></th> <th width=10><font face=arial size=2/><div align=center><strong>_add</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>position</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>AddBETA</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>addPvalue</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>domBETA</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>domPvalue</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>RecBETA</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>RecPvalue</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>bestP</strong></div></font></th> <th width=50><font face=arial size=2/><div align=center><strong>ModelUsed</strong></div></font></th> </tr>"; while ($row= mysql_fetch_array($result)) { //loop until all records from the table are selected //set difference color for ODD or EVEN row; $color2 = "#ffffff"; $color1 = "#cccccc"; $row_count = 0; while ($row= mysql_fetch_array($result)) { //loop until all records from the table are selected $row_color = ($row_count % 2) ? $color1 : $color2; echo "<tr bgcolor='$row_color'>"; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ 'CHR' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'SNP' ] ."</strong></div></font></th> "; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ 'minorA' ] ."</strong></div></font></th> "; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ 'majorA' ] ."</strong></div></font></th> "; echo "<th width=20><font face=arial size=2/><div align=center><strong>". $row[ 'MAF' ] ."</strong></div></font></th> "; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ 'NCHROBS' ] ."</strong></div></font></th> "; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ '_dom' ] ."</strong></div></font></th> "; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ '_rec' ] ."</strong></div></font></th>"; echo "<th width=10><font face=arial size=2/><div align=center><strong>". $row[ '_add' ] ."</strong></div></font></th>"; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'position' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'AddBETA' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'addPvalue' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'domBETA' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'domPvalue' ] ."</strong></div></font></th>"; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'RecBETA' ] ."</strong></div></font></th>"; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'RecPvalue' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'bestP' ] ."</strong></div></font></th> "; echo "<th width=50><font face=arial size=2/><div align=center><strong>". $row[ 'ModelUsed' ] ."</strong></div></font></th>"; echo "</tr>"; $row_count++; } echo "</table>"; ?> <p> </p><p> </p><p> </p> <! go back to main page> <form action="./index.html"> <p><input type="submit" value="Back to Home Page" name="Back to Home Page" > </p> </form> </body></html> Link to comment Share on other sites More sharing options...
chibineku Posted November 17, 2009 Share Posted November 17, 2009 You have a while loop inside a while loop at the end and you've only one closing brace. Link to comment Share on other sites More sharing options...
Ingolme Posted November 17, 2009 Share Posted November 17, 2009 This usually happens for one of two reasons: You've forgotten a closing brace '}' for an if(), while() or function() statement You've forgotten to close a string with ' or " Look through your code and indent it as well to see if you find it. It can't be that hard. I'd do it myself but I think that you should try on your own first. Link to comment Share on other sites More sharing options...
Synook Posted November 17, 2009 Share Posted November 17, 2009 Count your braces.Edit: whoops, someone else got there first. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 17, 2009 Share Posted November 17, 2009 Mismatched braces! Link to comment Share on other sites More sharing options...
yangkai9999 Posted November 17, 2009 Author Share Posted November 17, 2009 Mismatched braces!Thanks for everyone!!!!!!!!!!!!!!!!!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.