我是PHP的新手,我想在我的表格中显示一个名为music的列, 表名是作曲家, 但每次我发出错误: 致命错误:在第35行的/Applications/XAMPP/xamppfiles/htdocs/admin/music.php中的非对象上调用成员函数pg_fetch_object()
这是我的代码:
<?php
$host ="localhost"; //host
$username="root"; //username
$password ="";//password of the database
$dbName="wikiseda";//database Name
$tbl_name="users";
$tbl_music="music";
//______________________________
$connection=mysql_connect("$host","$username","$password") or die("can't connect sorry");
mysql_select_db($dbName,$connection) or die('can not select db');
$sql ="SELECT * FROM music";
$result = mysql_query($sql) or die(mysql_error());
while($row = $result-> pg_fetch_object()){
$musicname = $row->composer;
echo "$musicname";
}
?>
答案 0 :(得分:1)
试
while($row = mysql_fetch_object($result)){
$musicname = $row->composer;
echo "$musicname";
}
答案 1 :(得分:0)
将pg_fetch_object
更改为mysql_fetch_object