本帖最后由 ccasoft 于 2011-01-25 15:09:57 编辑

解决方案 »

  1.   

    mysql_query($sql) or die(mysql_error());
      

  2.   

    这个不是解决的方法,这是加了一个判断,如果执行SQL错误 ,就返回错误信息。不过本人还是认为SQL写法有问题或代码存在问题。
      

  3.   

     把你的sql打印出来单独在数据库上运行看看是不是有语法错误,或者数据不全一目了然了
      

  4.   

    问题自己解决了,谢谢mmidd,TottyAndBaty两位朋友的关注,是SQL语句的问题正确的源码是:
    <?php
    require 'config.php';
    $result = mysql_query('select * from boo3'); //执行查询数据
    while ($row = mysql_fetch_array($result, MYSQL_BOTH)) // 取一条数据
    {
    if(preg_match('/(\d{2,4}) (\d{7,8})-(\d{1,4})\/(\d{7,13})/', $row['phone'], $reg))
    {
    //匹配010 12345678-20/12345678901
    }
    elseif(preg_match('/(\d{2,4}) (\d{7,8})/', $row['phone'], $reg))
    {
    //匹配010 12345678
    }
    else
    {
    echo "error"."<br />";
    continue;
    }
    $telecode = $reg[1];
    $tel = $reg[2];
    $ext = $reg[3];
    $other = $reg[4];
    $sql = "update boo3 set telecode='".$telecode."',tel='".$tel."',other='".$other."' where id=".intval($row['id']);
    mysql_query($sql) or die(mysql_error()); //执行SQL
    echo "ok"."<br />";
    }
    mysql_free_result($result);
    ?>