blkshirt
10-19-2004, 12:28 PM
I found a little snippet of code I've modified (only to a very small extent) from the book "Programming PHP" by O'Reilly. I get a Fatal error: Call to a member function on a non-object in /home/j9d2k0/public_html/ohhstrack/phptest/index.php on line 34
in the code and I can't figure out why or what it is....
Here's the code itself:
<?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
}
?>
Here is line 34 on its own:
while ($q->fetchInto($row)){
Any ideas what is wrong with this? I've been trying to figure this out for a day now and it isn't happening... I'm very new to PHP so if you have any advice I'd appreciate it...
Thanks,
blkshirt
in the code and I can't figure out why or what it is....
Here's the code itself:
<?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
}
?>
Here is line 34 on its own:
while ($q->fetchInto($row)){
Any ideas what is wrong with this? I've been trying to figure this out for a day now and it isn't happening... I'm very new to PHP so if you have any advice I'd appreciate it...
Thanks,
blkshirt