NOOB Need Help

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by needcash, Dec 8, 2013.

  1. needcash

    needcash New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    i was trying to import a xml file via my admin script i use.When i go too test a xml file.I keep getting this error .I could paste it here due to it being over 1000 characters

    Any ideas on why is this happen.I am new too all this and just trying to fix it.So i do not have too keep adding offers manually
     

    Attached Files:

  2. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Not sure, but can tag names have spaces in them? If so, can that parser handle them?
     
  3. needcash

    needcash New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    What do u mean by that reply.I am a noob and still learning how php works and can u explain to me what u mean parser handle them?
     
  4. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Did you write the XML?

    You apparently have things like:

    Code:
    <Reporting Time>Instant</Reporting Time>
    The parser thinks the tag name is Reporting . Hence the closing tag should be </Reporting>
    The parser thinks that Time is a an attribute, and so should have a value.

    If you want to have Reporting Time be a tag name, then you have to get rid of the space.
    ReportingTime or Reporting-Time
     
  5. needcash

    needcash New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Would u be willing too do a teamviiewer with me to help me correct the issue please

     
  6. needcash

    needcash New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    And no i did not write the xml.I spoken too the owner of the script and he said it someone that he will get too but right now he is swamp since he does coding for a living and pc repairs as well.So i figure i would ask u guys for help
     
  7. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Well, whoever gave you that XML (the file, not the script) gave you improper formatted XML

    The first line is what you have. Improperly formatted.
    The second line is properly formatted.

    Code:
    <Reporting Time>Instant</Reporting Time>
    
    
    <Reporting_Time>Instant</Reporting_Time>
     
  8. needcash

    needcash New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    So i should change those lines too what u have in the code section.And it should work correctly
     
  9. needcash

    needcash New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I think i might be confusing you.This is the php code that i use
    PHP:
    <?php
    include("header.php");
    include(
    "sidebar.php");
                    if(
    $siteowner != || $aoff != 1){
    print
    "Access Denied"; include("footer.php"); exit();
    }
    if(!isset(
    $_GET['filename']) && !isset($_POST['upload'])){
    ?>
    <form action="" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="upload" value="Submit" />
    </form>
    <?php
    }
    if(
    $_POST['upload']){
    if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {

        if (
    file_exists("xml/" $_FILES["file"]["name"]))
          {
    unlink("xml/" $_FILES["file"]["name"]);
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "xml/" $_FILES["file"]["name"]);
          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "xml/" $_FILES["file"]["name"]);
          }
        }
        
    $filename=$_FILES["file"]["name"];
        
    header("Location: testxml.php?filename=".$filename."");
      }
      if(
    $_GET['filename']){
      
    $filenameasql($_GET['filename']);
    $file 'xml/'.$filename;
    $string file_get_contents($file);
    $cid asql($_POST['campid']);
    $name asql($_POST['oname']);
    $req asql($_POST['req']);
    $url asql($_POST['url']);
    $reward asql($_POST['cash']);
    $points asql($_POST['points']);
    if(
    $reward >= "2.00"){
    $lock "1";
    }else{
    $lock "0";
    }
    if(
    $points >= "200"){
    $lock "1";
    }else{
    $lock "0";
    }
    $country asql($_POST['countries']);
    $type asql($_POST['cat']);
    $aff asql($_GET['aff']);
    $times time();
    $fullfile "xml/".$filename;
    function 
    delete_book_id($ids){
    global 
    $fullfile;
    $data simplexml_load_file($fullfile);
    $data_count count($data->item);
    for(
    $i 0$i $data_count$i++)
    {
    //basically what you want to remove
    if(($data->item[$i]->id == $ids))
    {
        unset(
    $data->item[$i]);
    }
    }
    file_put_contents($fullfile$data->saveXML());
    }

    if(
    $_POST['add']){
    mysql_query("INSERT INTO offers (`id`,`campid`,`name`,`desc`,`url`,`reward`,`points`,`country`,`type`,`locked`,`active`,`aff`,`d_added`) VALUES ('','$cid','$name','$req','$url','$reward','$points','$country','$type','$lock','1','$aff','$times')");
    delete_book_id($cid);
    header("Location: testxml.php?aff=".$aff."&filename=".$filename."");
    }

    $xml = new SimpleXMLElement($string);
    //Loop trough multiple products
    print"<table border='1' bordercolor='#6600FF' style='width='100%' cellpadding='3' cellspacing='3'>
    <th>Campaign Name</th><th>Countries</th><th>Rate</th><th>Cash</th><th>Points</th>
    <form action='' method='GET'>
    <input type='hidden' name='filename' value='"
    .$filename."' />
    <select name='aff'>"
    ;
    if(
    $_GET['aff']){
    $affi asql($_GET['aff']);
    print
    "<option value='".$affi."'>".$affi."</option>";
    }else{
    print
    "<option value='0'>Select an Affiliate</option>";
    }
    $affs=mysql_query("SELECT * FROM `affiliates`");
            while(
    $affi=mysql_fetch_array($affs))
            {
                print
    "<option value='{$affi['name']}'>{$affi['name']}</option>";
            }
                            print
    "</select><input type='submit' value='Select Affiliate' /></form>";


    foreach(
    $xml->item as $item)
    {
    $count count(explode(", ",$item->countries));
    if(
    $count >= 5){
    $country "ALL INTL";
    }
    else{
    $country $item->countries;
    }
    $rate number_format((float)$item->rate2'.''');
    $crates $rate 0;
    $prates $rate 45;
    $crate number_format((float)$crates2'.''');
    $prate number_format((float)$prates2'.''');
        echo
    '<tr><td><form action="" method="POST"><input type="hidden" name="countries" value="'.$item->countries.'" /><input type="hidden" name="url" value="'.$item->url.'" /><input type="hidden" name="campid" value="'.$item->id.'" /><input type="hidden" name="oname" value="'.$item->name.'" />'.$item->name.'<br /><font color="limegreen" size="2">Incent: '.$item->incent.'</font><br /><select name="req" style="width:200px"><option value ="'.$item->requirements.'">'.$item->requirements.'</option></select>
    <select style="width:200px" name="cat" id="cat">'
    ;
    $cats=mysql_query("SELECT * FROM `offer_cats`");
    while(
    $off=mysql_fetch_array($cats)){
    $cnames = array($off['name']);
    $cnamess implode(","$cnames);
    $cname explode(","$cnamess);
    foreach(
    $cname as $category){
        echo 
    '<option value="'.$off['id'].'">'.$category.'</option>';
    }
    }
    echo
    '</select><input type="submit" name="add" value="+" /></td>';

        echo 
    '<td>'.$country.'</td>';
        echo 
    '<td>'.$item->rate.'</td>';
        echo 
    '<td><input type = "text" name="cash" value="'.$crate.'" style = "width:75px" /></td>';
        echo 
    '<td><input type = "text" name="points" value="'.$prate.'" style = "width:75px" /></td></form>';
      
    // echo $item->incent;
      //  echo '<br/>';
    }
    ?>
    </tr>
    </table>
    <?php
    }
    include(
    "footer.php");
    ?>
    After i try too upload a xml file,I get the error message in the first post.Is there any too fix that from happening and is there way too get the php file too work with csv formats as well
     

Share This Page