这个PHP MYSQL更新命令中的错误是什么?

时间:2011-04-26 09:47:25

标签: php mysql

更新命令中的错误是什么?它不更新数据库?     

if($action=="new")
{
    $query1="insert into activity_basic_info(activity_id) values($activity_id)";
    $result1=mysql_query($query1);
    if($result1)
        echo "01";
    else
        echo "00";
}
else
{
    $query="update activity_basic_info set";
    if(isset($name))
        $query = $query." name='$name',";
    if($describtion!="" && describtion!=NULL)
        $query = $query." describtion='$describtion',";
    if($city!=NULL&&$city!="")
        $query = $query." city_id=$city,";
    if($region!=NULL)
        $query = $query." region_id=$region,";
    if($street!=NULL)
        $query = $query." street_id=$street,";
    if($telephone!="")
        $query = $query." telephone=$telephone,";
    if($email!=NULL&&$email!="")
        $query = $query." email='$email',";
    if($url!=NULL&&$url!="")
        $query = $query." url='$url'";
    else
        $query = $query."url=''";

    $query = $query." where activity_id=$activity_id";

    $result=mysql_query($query);
        echo $query;
}
?>

1 个答案:

答案 0 :(得分:2)

你应该检查$ result = mysql_query($ query)的成功;然后如果为false,检查mysql_error()http://php.net/manual/en/function.mysql-error.php

的值