php报错Parse error: syntax error, unexpected ';', expecting T_FUNCTION in 。。。
报错信息:Parseerror:syntaxerror,unexpected';',expectingT_FUNCTIONinE:\APMServer5\APMServ5...
报错信息:Parse error: syntax error, unexpected ';', expecting T_FUNCTION in E:\APMServer5\APMServ5.2.6\www\htdocs\amfphp\services\tutorials\ServerInfoService.php on line 38
"
代码如下:
<?php
require_once "./Server.php";
class ServerInfoService{
/**
* Get a list of one Server information
* @returns An Array of Serverinfo
*/
function getList(){
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connnect: '. mysql_error());
}
echo "Connected to MySQL!!!!!!";
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM server_info");
while($row = mysql_fetch_array($result))
{
$p = array();
for($a = 0; $a <count($row); $a++){
$server = new Server();
$server->id = $row[$a][0];
$server->server_ip = $row[$a][1];
$server->mac= $row[$a][2];
$server->cpu_amount = $row[$a][3];
$server->cpu_MHz = $row[$a][4];
$server->memory = $row[$a][5];
$server->v_amount = $row[$a][6];
$server->v_type = $row[$a][7];
$server->v_name = $row[$a][8];
$p[] = $server;
}
return $p;
mysql_close($con);
}
}
?>
请问是什么问题?不能在类的内部进行数据库查询和赋值操作么?如果是,应该如何通过调用方法实现返回数组。 展开
"
代码如下:
<?php
require_once "./Server.php";
class ServerInfoService{
/**
* Get a list of one Server information
* @returns An Array of Serverinfo
*/
function getList(){
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connnect: '. mysql_error());
}
echo "Connected to MySQL!!!!!!";
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM server_info");
while($row = mysql_fetch_array($result))
{
$p = array();
for($a = 0; $a <count($row); $a++){
$server = new Server();
$server->id = $row[$a][0];
$server->server_ip = $row[$a][1];
$server->mac= $row[$a][2];
$server->cpu_amount = $row[$a][3];
$server->cpu_MHz = $row[$a][4];
$server->memory = $row[$a][5];
$server->v_amount = $row[$a][6];
$server->v_type = $row[$a][7];
$server->v_name = $row[$a][8];
$p[] = $server;
}
return $p;
mysql_close($con);
}
}
?>
请问是什么问题?不能在类的内部进行数据库查询和赋值操作么?如果是,应该如何通过调用方法实现返回数组。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询