Jump to content

Simple PHP problem.


TheLostGuru

Recommended Posts

Hi, I am brand new to PHP.  I have been reading a book called PHP and MySQL and I am trying to run a sample script, but I cannot get it to work.  All I am trying to do is pull information from a table in a database and print it in a table.  This is my code

//All of my connection takes place up here
function displayScores($result) {
print "<h1>Mathlete Scores</h1>\n";

print 	"\n<table>\n<tr>\n" .
		"\n\t<th>Name</th>" .
		"\n\t<th>Correct</th>" .
		"\n\t<th>Incorrect</th>" .
		"\n\t<th>Type</th>" .
		"\n\t<th>Time</th>" .
		"\n<\tr>";

while($row = @ mysql_fetch_row($result)) {
	print "\n<tr>"
	foreach($row as $data) {
		print "\n\t<td> {$data} </td>";
	}
	print "\n</tr>";

}

print "\n</table>\n";
}

$query = "SELECT * FROM TABLE01";
$result = @ mysql_query ($query);
displayScores($result);

 

When I test the script in a browser, I get this error:

Parse error: parse error in  on line 19

Line 19 refers to "foreach($row as $data) {"

Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/48405-simple-php-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.