mysql_query("update class_temp,class_appointment set  class_temp.a=class_appointment.reason,
class_temp.b=class_appointment.username
 where class_appointment.date='2011-08-13' and class_appointment.classroom='t612' and class_appointment.time='1' and class_temp.id='0'");
我执行了之后没有反应,是不是SQL的语法问题呀???

解决方案 »

  1.   

    建议拆开写$query = "update class_temp,class_appointment set class_temp.a=class_appointment.reason,
    class_temp.b=class_appointment.username
     where class_appointment.date='2011-08-13' and class_appointment.classroom='t612' and class_appointment.time='1' and class_temp.id='0'";
    mysql_query($query);这个语法是没问题的,关键是要注意顿号,分号等格式要正确(不是中文输入法输进去的),还有就是看数据库里面符合该条件的,有木有。
      

  2.   

    我在phpMyAdmin的SQL里直接运行update class_temp,class_appointment set  class_temp.1=class_appointment.reason,
    class_temp.1_teacher=class_appointment.username
     where class_appointment.date='2011-08-21' and class_appointment.classroom='jc612' and class_appointment.time='1' and class_temp.id='7'就可以运行,也是预期结果,但是我在PHP中使用变量的方式进行数据库操作就没有任何效果for($week_temp2=(7-$week_temp);$week_temp2<(7+$week_temp);$week_temp2++)
    {
    $date=date("Y-m-d",strtotime("+$week_temp2 days"));
    for($i=1;$i<=7;$i++)
    {
    $str=$i."_teacher";
    mysql_query("update class_temp,class_appointment set  class_temp.$i=class_appointment.reason,
    class_temp.$str=class_appointment.username
     where class_appointment.date='$date' and class_appointment.classroom='$classroom' and class_appointment.time='$i' and class_temp.id='$m'");
    }
    $m++;
    }
    请问是什么原因?是不是符号问题?是不是还要用“`”之类的??
      

  3.   

    你可以一句一句的打印出来看看,看究竟错误在哪里的比如接着我上面的代码:echo "$query";(重点查看的部分)   echo "$date";等可以逐步排查错误
      

  4.   

    所以建议你,把变量等之类的分开写,一个一个的打印出来看最后,要重点看echo "$query";中的变量被数据代替了没有等