在mysql命令列下執行都沒問題的命令,為何寫到php中執行就失敗呢?

edited 十月 2013 in PHP新手區
以下字串我直接在mysql命令列下執行都沒問題,為何寫到php中執行就失敗呢?
ex: $list = mysql_query($sql,$link) $sql即下列字串\

SELECT r.re_serial,r.re_parent_id,r.re_name, o.name, t.re_name as yyy FROM fourm_re_discuss AS r, fourm_discuss AS o, fourm_re_discuss AS t WHERE r.re_id=154 and r.re_parent_id=410 and o.serial=r.re_id and t.re_serial=r.re_parent_id order by r.re_time;


原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=324

評論

  • edited 十一月 2004
    執行後,browser一片空白,無任何php錯誤訊息\
    但在mysql命令列下的執行結果則正確無誤如下:
    +
    +
    +
    +
    +
    +
    | re_serial | re_parent_id | re_name | name | yyy |
    +
    +
    +
    +
    +
    +
    | 413 | 410 | ZZZ | new | AA |
    | 416 | 410 | sk2 | new | AA |
    | 418 | 410 | AA | new | AA |
    | 419 | 410 | REPLYMAN | new | AA |
    | 422 | 410 | 秘密客 | new | AA |
    | 426 | 410 | Blog | new | AA |
    +
    +
    +
    +
    +
    +
    6 rows in set (0.02 sec)
  • edited 十一月 2004
    而如果我拿掉以下3行字串\
    1. t.re_name as yyy
    2. fourm_re_discuss AS t
    3. and t.re_serial = r.re_parent_id

    讓sql命令字串變成如下,則php就能執行正常,.....why?
    SELECT r.re_serial, r.re_parent_id, r.re_name, o.name FROM fourm_re_discuss AS r, fourm_discuss AS o WHERE r.re_id=154 and r.re_parent_id=410 and o.serial=r.re_id order by r.re_time;

Sign In or Register to comment.