townid = (select id from town where place like '%$mylist[1]%')
这句不行,()里需要返回唯一值,所以你用%很有可能返回多个ID值。
另外,mylist[1]是数组吗?如果是数组,应该不能在字符串里直接使用才对。PHP不太清楚。估计应该是"..."+mylist[1]+"..."的格式

解决方案 »

  1.   

    php中好像不能在''中用变量,改成""试试!!
      

  2.   

    $mylist[1]是$mylist数组里的第二个元素值
      

  3.   

    在phpmyadmin里执行的结果是这样的:#1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select id from town where place like '%绍兴%') and tjflag=1 LIM
      

  4.   

    呵呵,你的mysql版本支持子查询吗?