select mem_name from tb_mem_001 where mem_idno = '$mem_upda_idno'如上的语句,mem_idno这个字段为 char(5),$mem_upda_idno是一个文本框Post过来数值。我的问题是,我怎么都无法取到mem_name的值,总是空的。在Mysql-Front里试过,以$mem_upda_idno的值为00100为例,当在Where子句中写为mem_idno = '00100'的时候,查询记录为空。
但当写为mem_idno = 00100的时候,查询到有记录。之前好像都没注意过这个问题,搞了很久,没办法,还请哪位高手指教为盼。

解决方案 »

  1.   

    select mem_name from tb_mem_001 where mem_idno = '".$_post['mem_upda_idno']."';怎么这个问题好面熟啊?是不是在web开发中也有问过了?
      

  2.   

    select mem_name from tb_mem_001 where mem_idno = '$mem_upda_idno'注意单引号的用法。
    单引号里的所有字符都不会转义,只是当作简单的字符串来操作。
    所以你的应该改成:
    $sql = "select mem_name from tb_mem_001 where mem_idno = $mem_upda_idno";或者:$sql = 'select mem_name from tb_mem_001 where mem_idno = '.$mem_upda_idno;