tensionx Posted August 2, 2006 Share Posted August 2, 2006 I broke this down and tested each section.Somehow i am missing something in the last line of my code.I could use some helping eyes.Here is my error[b]"Parse error: syntax error, unexpected $end in /home/wekillmo/public_html/tablemaker.php on line 37"[/b][code]<html> <table border="0" CELLSPACING="0" CELLPADDING="10" align="center"> <?php //db connect and select $db = @mysql_connect("localhost", "XXX", "XXX"); if( ! ($db = @mysql_connect("localhost", "name", "password")) ) { } else { mysql_select_db("XXX",$db) or die("Select DB Error: ".mysql_error()); } $result=mysql_query ("SELECT * FROM XXX"); $count = 1; $column = 1; //loop statement while($myrow = mysql_fetch_array($result)) {{ // first column display if ($column == 1) { //field is the column in your table printf("<tr><td>%s</td>",$myrow["name"]); } else{ //second column display printf("<td>%s</td></tr>",$myrow["class"]); } $count += 1; $column = $count % 2; } ?> </table></html> [/code] Link to comment https://forums.phpfreaks.com/topic/16375-strange/ Share on other sites More sharing options...
ryanlwh Posted August 2, 2006 Share Posted August 2, 2006 why do you have an extra { after the while clause?? Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68108 Share on other sites More sharing options...
ryanlwh Posted August 2, 2006 Share Posted August 2, 2006 billyBob i guess you mean also taking out the ![code]if( $db = @mysql_connect("localhost", "name", "password") ) { mysql_select_db("XXX",$db) or die("Select DB Error: ".mysql_error()); exit();}[/code] Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68113 Share on other sites More sharing options...
tensionx Posted August 2, 2006 Author Share Posted August 2, 2006 I started doing PHP yesterday Excuse the syntax :)I come from ASP and am not tooo comfortable in this world yet. Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68115 Share on other sites More sharing options...
BillyBoB Posted August 2, 2006 Share Posted August 2, 2006 nvm i thought that was the connect srry :) my bad i will delete taht post :) ;D Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68117 Share on other sites More sharing options...
tensionx Posted August 2, 2006 Author Share Posted August 2, 2006 Well. Took out the extra {Now its saying[b]"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/wekillmo/public_html/tablemaker.php on line 20" [/b] lol...my select is really simpleselect * from XXXXI just need a damn excel style table...$result=mysql_query ("SELECT * FROM XXX"); Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68124 Share on other sites More sharing options...
ryanlwh Posted August 2, 2006 Share Posted August 2, 2006 now it's telling you there's something wrong with the query. what's your query? Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68125 Share on other sites More sharing options...
tensionx Posted August 2, 2006 Author Share Posted August 2, 2006 $result=mysql_query ("SELECT * FROM XXX"); when i throw a {at the endIt stops giving me that error.Then it sends me on my merry way to line 32. The last line... "</html>"and saysParse error: syntax error, unexpected $end in /home/wekillmo/public_html/tablemaker.php on line 32 Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68129 Share on other sites More sharing options...
AndyB Posted August 2, 2006 Share Posted August 2, 2006 Can we please see the complete code (with the changes and unchanges you've made as suggested in this thread).But before you do, reformat your code and indent the loops so you can see exactly what loops are open and that they are properly closed in sequence.You can't just arbitrarily throw in unmatched curly braces.The sensible was to debug is always to report the error and the query used that generated it. For example:[code]$query = "SELECT * FROM table_name";$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);[/code]Then you'll know just why the query failed. Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68146 Share on other sites More sharing options...
ryanlwh Posted August 2, 2006 Share Posted August 2, 2006 are you really throwing in XXX as the table name???? Link to comment https://forums.phpfreaks.com/topic/16375-strange/#findComment-68156 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.