在这个问题上苦苦挣扎..我的SQL查询在PHP myAdmin中运行,但不在页面上..
网址: http://www.copleycaravanservices.co.uk/Caravans.php?room_id=1&foreign_id=1 还有另一个查询适用于url的room_id部分
不起作用的代码:
<?php
require_once('db_config.php');
mysql_select_db($dbname, $db);
$sql1 = "SELECT * FROM `SS_hotel_booking_multi_lang`
WHERE `foreign_id` = " . $_GET['foreign_id'] . "
AND `locale` = '1'
AND `field` = 'description'
AND `source` = 'data'";
$result1 = mysql_query($sql1, $db) or die(mysql_error());
$CaravanDesc = mysql_fetch_assoc($result1);
?>
数据库:(希望这显示正确!)
id foreign_id model locale field content source
7365 1 pjRoom 1 name Promenade 654 data
7366 1 pjRoom 1 description This caravan sleeps 6 data
7371 2 pjRoom 1 name Butlins Sandhills 14 data
7372 2 pjRoom 1 description 4 Day Passes included data
答案 0 :(得分:0)
我认为这应该通过删除列名
的引号来完成 <?php
require_once('db_config.php');
mysql_select_db($dbname, $db);
$sql1 = "SELECT * FROM `SS_hotel_booking_multi_lang`
WHERE foreign_id = " . $_GET['foreign_id'] . "
AND locale = '1'
AND field = 'description'
AND source = 'data'";
$result1 = mysql_query($sql1, $db) or die(mysql_error());
$CaravanDesc = mysql_fetch_assoc($result1);
?>