我有这段代码
//Php SOAP request //
<?php echo $hotel->hotelCode?>
//MySQL query //
<?php
$DBTYPE = 'mysql';
$DBHOST = 'localhost';
$DBUSER = 'dbuser';
$DBPASSWORD = 'pwd';
$DBNAME = 'dbname';
$link = mysql_connect($DBHOST, $DBUSER, $DBPASSWORD);
mysql_select_db($DBNAME);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$Hotel_id=".'$hotel->hotelCode'.";
$sql = mysql_query("SELECT HotelName FROM Hotels where HotelCode=$Hotel_id");
$results = mysql_query($sql);
var_dump($results);
?>
但它的回归布尔(假) 我已经用php SOAP请求提取代码,酒店名称我将它存储在mysql数据库中 你能告诉我我做错了吗?
答案 0 :(得分:0)
您的查询是:
$sql = mysql_query("SELECT HotelName FROM Hotels where HotelCode=$Hotel_id");
我猜酒店代码是一个字符串。在这种情况下,您需要额外的报价:
$sql = mysql_query("SELECT HotelName FROM Hotels where HotelCode = '$Hotel_id'");