dongzhang7961 2015-03-22 13:32 采纳率: 0%
浏览 406
已采纳

WHERE子句中的多个查询

Struggling with this one.. my sql query works in PHP myAdmin but not on the page..

The url: http://www.copleycaravanservices.co.uk/Caravans.php?room_id=1&foreign_id=1 There is also another query which works for the room_id section of the url

The code that isnt working:

<?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);
?>

The database: (Hope this displays correctly!)

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
  • 写回答

1条回答 默认 最新

  • duankui6150 2015-03-22 15:26
    关注

    I think this should be done like this try by removing quotes of column name

     <?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);
        ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?