hey folks!
I am trying to get records from a sql database in a php page. I want to display 2 fields & their values on the page as a table.
Unfortuantly, I am a newbie at server-side stuff and would like some help.
I have had my go but am getting ugly errors!
[CODE]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Our List of Jokes</title>
<meta http-equiv=”content-type”
content=”text/html; charset=iso-8859-1″ />
</head>
<body>
<?
$username=”a9362702_admin”;
$password=”PASSWORD HERE”;
$database=”a9362702_games”;
mysql_connect(sql1.000webhost.com,$username,$password);
mysql_select_db($database);
$query=”SELECT * FROM tablename”;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<table border=”0″ cellspacing=”2″ cellpadding=”2″>
<tr>
<th><font face=”Arial, Helvetica, sans-serif”>Game Name</font></th>
<th><font face=”Arial, Helvetica, sans-serif”>Game URL</font></th>
</tr>
<?
$i=0;
while ($i < $num) {
$field1-name=mysql_result($result,$i,”gname”);
$field2-name=mysql_result($result,$i,”gurl”);
?>
<tr>
<td><font face=”Arial, Helvetica, sans-serif”><? echo $field1-name; ?></font></td>
<td><font face=”Arial, Helvetica, sans-serif”><? echo $field2-name; ?></font></td>
</tr>
<?
$i++;
}
echo “</table>”;
</body>
</html>
This is the error I am getting:
[CODE]Parse error: syntax error, unexpected T_DNUMBER in /home/a9362702/public_html/comped2.php on line 15
comped2.php is the 1st code i gave you. It is online at
[URL=”http://thelinker.net63.net/comped2.php”]This place