I found the basis for my code on Page 13 of this
book
So I changed the connection string and added more columns to the table to show all the data that is in the mySQL database. But I still get an error on line 34 that I can't figure out for the life of me...
Here's the code:
<?php
//connect to the database
$dbh=mysql_connect ("localhost", "j9d2k0_j9d2k0ohh", "<password here>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("j9d2k0_j9d2k0ohhstrack");
//}
//query database for information
$sql = "SELECT ohsaabdiv1.Event,ohsaabdiv1.Effort,ohsaabdiv1.Name,ohsaabdiv1.School,ohsaabdiv1.Location,ohsaabdiv1.Year
FROM ohsaabdiv1
ORDER BY ohsaabdiv1.Event ASC";
$q = $dbh->query($sql);
if (DB::iserror($q)){
die($q->getMessage());
}
//generate the table
while ($q->fetchInto($row)){
?>
<tr><TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $row[0] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $row[1] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $row[2] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $row[3] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $row[4] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $row[5] ?></td>
</tr>
<?php
}
?>
Line 34 is this
while ($q->fetchInto($row)){
Anybody know where I went wrong? I'm VERY new to PHP and I am clueless as to why this error is coming up... Especially since it was in a book!!!!
Thanks for the help!
blkshirt