本帖最后由 qqmnme 于 2011-11-10 18:45:30 编辑

解决方案 »

  1.   

    foreach( $arr_hang as $lie ){
    mysql_query("update `user_list` set ext1 = ext1 + 2500  where `username`='$lie'" );
    if( mysql_affected_rows >= 0 )
         echo "更新成功:".$lie;
    else
         echo "ERROR:".mysql_error();

    纳闷的是你写的代码也没有看出有错误
      

  2.   

    这是全部代码、
    <?php
    $dbhost='localhost';//数据库IP
    $dbname = 'sex';//数据库名
    $dbuser = 'test';//数据库用户名
    $dbpassword = '123';//用户密码
    $conn = mysql_connect($dbhost,$dbuser,$dbpassword);
    mysql_select_db($dbname,$conn);
    mysql_query("set names gb2312");$content=fread(fopen("pay5.txt",'r+'),filesize("pay5.txt"))."";
    $arr_hang=explode("\n",$content);foreach( $arr_hang as $lie ){
    mysql_query("update `user_list` set ext1 = ext1 + 2500  where `username`='$lie'" );
    if( mysql_affected_rows >= 0 )
         echo "更新成功:".$lie;
    else
         echo "ERROR:".mysql_error();

    $of = fopen("pay5.txt",'w+');//创建并打开wml
    if($of){
     fwrite($of,$s);//把执行文件的结果写入txt文件
    }?>
      

  3.   

    我写错了一点 mysql_affected_rows() 是个方法
     你把 $arr_hang 打印出来,和数据库中的数据比对一下就知道为啥了
      

  4.   


    <?php
    $dbhost='localhost';//数据库IP
    $dbname = 'sex';//数据库名
    $dbuser = 'test';//数据库用户名
    $dbpassword = '123';//用户密码
    $conn = mysql_connect($dbhost,$dbuser,$dbpassword);
    mysql_select_db($dbname,$conn);
    mysql_query("set names gb2312");
    // 读取文件
    $readfile = fopen("pay5.txt",'r+');
    $content=fread(fopen("pay5.txt",'r+'),filesize("pay5.txt"))."";
    fclose( $readfile);
    // 分行
    $arr_hang=explode("\n",$content);print_r( $arr_hang);
    echo "<br/>";foreach( $arr_hang as $lie ){
    mysql_query("update `user_list` set ext1 = ext1 + 2500 where `username`='$lie'" );
    if( mysql_affected_rows() >= 0 )
      echo "更新成功:".$lie;
    else
      echo "ERROR:".mysql_error();
    }  // 写入
    $of = fopen("pay5.txt",'w+');//创建并打开wml
    if($of){
     fwrite($of,$s);//把执行文件的结果写入txt文件    $s未定义吧!
    }
    ?>每次更新不管有没有成功都会打印出信息的
    现在想想也许有乱码的可能。