Php HTTP错误:HTTP头后不存在数据
我正在尝试查询数据库并将值返回给客户端。这是我的代码,有两个函数。速率应该以db为单位Php HTTP错误:HTTP头后不存在数据,php,mysql,soap,Php,Mysql,Soap,我正在尝试查询数据库并将值返回给客户端。这是我的代码,有两个函数。速率应该以db为单位 public function connect($description){ //creating connection $con = new mysqli('localhost','root','','ci_vetro'); //mysql_connect('localhost','root','') or die("Connection Error: ".mysql_er
public function connect($description){
//creating connection
$con = new mysqli('localhost','root','','ci_vetro');
//mysql_connect('localhost','root','') or die("Connection Error: ".mysql_error());
//mysql_select_db('ci_vetro');
//check connection
if($con->connect_error):
die('Connection Error: '. $con->connect_error);
endif;
$sql= "SELECT * from. exchange_rates where description=.'$description'.";
$result= $con->query($sql);
if($result->num_rows > 0):
while($row = $result->fetch_assoc()) :
$rate=$row["rate"]. "<br>";
endwhile;
else:
echo "0";
endif;
$con->close();
return $rate;
}
public function getCurrency($currency) {
$rate=connect($currency);
switch ($currency){
case 'USD':
return int($rate);
break;
default:
return 0;
break;
}
}
公共功能连接($description){
//创建连接
$con=newmysqli('localhost','root','','ci_vetro');
//mysql_connect('localhost','root','')或die(“连接错误:”.mysql_Error());
//mysql_select_db('civetro');
//检查连接
如果($con->connect\u错误):
die('Connection Error:'。$con->connect_Error);
endif;
$sql=“SELECT*from.exchange\u rates,其中description=.$description.”;
$result=$con->query($sql);
如果($result->num_rows>0):
而($row=$result->fetch_assoc()):
$rate=$row[“rate”]。“
”;
结束时;
其他:
回声“0”;
endif;
$con->close();
回报率:$;
}
公共函数getCurrency($currency){
$rate=connect($currency);
交换机(货币){
“美元”一案:
返回整数(费率);
打破
违约:
返回0;
打破
}
}
mysql->query如果查询有语法错误,则返回false。因此,您尝试获取布尔变量的“num_行”。启用错误以查看发生了什么<代码>$sql=“选择*自.exchange\u汇率,其中description=。$description.”代码>