我不断收到一条错误消息:
致命错误:在第 46 行 C:\wamp\www\Website\index.php 中的非对象上调用成员函数 execute()
下面是我的代码。可能出了什么问题?我现在只是使用股票根帐户。
<?php
$dbserver="localhost";
$username="root";
$password="";
$connection=mysql_connect("$dbserver","$username","$password")or die("could not connect to the server");
//execute an SQL statement and return a recordset
$rs = $connection->execute("SELECT product_name FROM products");
$num_columns = $rs->Fields->Count();
echo "<table border='1'>";
echo "<tr><th>Name</th></tr>";
while (!$rs->EOF) //looping through the recordset (until End Of File)
{
echo "<tr>";
for ($i=0; $i < $num_columns; $i++) {
echo "<td><a href=\"product.php?id=" . $rs->Fields('id').value . "\">" . $rs->Fields($i)->value . "</a></td>";
}
echo "</tr>";
$rs->MoveNext();
}
echo "</table>";
//close the recordset and the database connection
$rs->close();
$rs = null;
$conn->close();
$conn = null;
?>