Jump to content
Fórum Script Brasil
  • 0

Xml


Eric Freitas

Question

Pessoal, qual o erro no meu xml, e como fazer p/ sobrepor o arquivo criado?

mysql_connect("localhost","root","");
    mysql_select_db("apmp");
    
    $_query = "select name,username,password from jos_users";
    $_sql = mysql_query($_query);
    if($_sql){
        $_xml = '<?xml version="1.0" encoding="utf-8">';
        $_linhas = mysql_numrows($_sql);
        $_colunas = mysql_num_fields($_sql);
        
        
        for($_i=0;$_i<$_linhas;$_i++){
            $_xml.='<usuarios>';
            for($_j=0;$_j<$_colunas;$_j++){
                $_field = mysql_field_name($_sql,$_j);
                $_xml.= '<'.$_field.'>'.mysql_result($_sql,$_i,$_j).'</'.$_field.'>';
            }
            $_xml.='</usuarios>';
        }
    }else{
        echo 'erro';
        exit();
    }

    //print $_xml;


    $_msgErro = "Erro ao geral XML";
    
    if(file_exists($_arquivo = fopen ("c:/eric/usuarios.xml", "x+"))) echo'';
    elseif(!$_arquivo){
        echo$_msgErro; exit;
    }elseif(!fwrite($_arquivo,var_dump($_xml))){
        echo$_msgErro; exit;
    }else echo'Arquivo criado com sucesso!';
    
    fclose();

obs eu tentei fazer esta alteração mas não deu certo, por isso ele nem deve estar gerando o xml.

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.6k
×
×
  • Create New...